3

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?

1 Answer 1

2

Of course, as soon as I posted the question, I figured out the answer. These entries from the system log explain what is happening:

Apr 11 21:51:02 vm-**** systemd[1]: sysinit.target: Found ordering cycle on systemd-tmpfiles-setup.service/start
Apr 11 21:51:02 vm-**** systemd[1]: sysinit.target: Found dependency on mnt-resource.mount/start
Apr 11 21:51:02 vm-**** systemd[1]: sysinit.target: Found dependency on cloud-init.service/start
Apr 11 21:51:02 vm-**** systemd[1]: sysinit.target: Found dependency on NetworkManager.service/start
Apr 11 21:51:02 vm-**** systemd[1]: sysinit.target: Found dependency on dbus.service/start
Apr 11 21:51:02 vm-**** systemd[1]: sysinit.target: Found dependency on basic.target/start
Apr 11 21:51:02 vm-**** systemd[1]: sysinit.target: Found dependency on sysinit.target/start
Apr 11 21:51:02 vm-**** systemd[1]: sysinit.target: Job systemd-tmpfiles-setup.service/start deleted to break ordering cycle starting with sysinit.target/start

(Not logged: sysinit.target depends on systemd-tmpfiles-setup.service.)

Systemd breaks the cycle by ignoring the override requirement, which is for the best. Thus, if I want to do this with systemd-tmpfiles (and I do), then I'll need to trigger it separately from systemd-tmpfile-setup. I'll probably add a separate custom service.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .