I'm trying to use systemd-tmpfiles to manage files on the "temporary disk" of a Linux (CentOS Stream 8) VM on Azure. The systemd-tmpfiles
configuration seems to be correct, as judged by running systemd-tmpfiles --create
manually when the system is up. It is not working with the systemd-tmpfiles-setup
service, however, in that that service creates the files in the mount point directory instead of on the mounted filesystem. Of course, that moots the whole exercise.
I presume that that is happening because systemd-tmpfiles-setup
runs before the temporary disk is mounted, so I have attempted to resolve it by applying a RequiresMountsFor
property via a configuration override:
/etc/systemd/system/systemd-tmpfiles-setup.service.d/override.conf
[Unit]
RequiresMountsFor=/mnt/resource
Systemd seems to recognize that, as judged by systemctl list-dependencies systemd-tmpfiles-setup
listing the appropriate mount unit, but upon reboot, it still creates the wanted files in the mount point directory instead of on the mounted temporary disk.
Possibly it is relevant that the wanted mount unit does not have an explicit unit file; I am relying on systemd to generate the unit by scanning /etc/fstab
, as it indeed seems to be doing.
/etc/fstab:
# ...
/dev/disk/cloud/azure_resource-part1 /mnt/resource auto defaults,nofail,x-systemd.requires=cloud-init.service,comment=cloudconfig 0 2
What am I missing? Is there a good reason why what I'm doing shouldn't work?