The system is Ubuntu Server 18.04 LTS on VM in Azure cloud, with PostgreSQL 12 installed. Data storage for PostgreSQL is on RAID composed from "remote" managed disks. However, every Azure VM has ephemeral disk which is on SSD on host machine, and therefore has better IOPS and latency. I want to use this disk for postgres temporary tablespace, so it is used for disk sorts etc.
This ephemeral disk is mounted "automatically" as
/mnt (it has record in
/etc/fstab) but it is owned by
root, and of course it can be empty after reboot (if the VM was reallocated for example). So, at start I need to create subdirectory in it (if it does not exists already),
chown it to
postgres, to make sure it is in place once the postgres cluser starts.
What is the best practice of doing this?
Maybe creating systemd service for my script, and set it as dependency for postgres service, like suggested here: https://askubuntu.com/a/1151089 I am fairly new to Linux, I would appreciate some guidance here, thanks!