My systemd linux systems show several tmpfs directories (/run, /dev/shm, /run/lock and on my raspberry also /sys/fs/cgroup).
Alas, I cannot find where these top directories are created.
I know that systemd-tmpfiles creates tmp files according to config files in tmpfiles.d/* in /etc and /usr/lib, but I only see subdirectories defined in those, not the top directories themselves.
1 Answer
There is a distinction between creating a directory and mounting something on that directory. Mounting is done in core systemd code; there is a hard-coded list of "API mounts" such as /proc that it performs on every startup – but this isn't 100% tied to mountpoint creation.
/run, in particular, exists on your root filesystem and only needs to be created once – typically during OS install time – and even though a tmpfs needs to be mounted there on every boot, the underlying "mount point" directory continues to exist in the same way that /etc continues to exist.
/run/lock and /dev/shm do need to be re-created, as they are themselves within tmpfs; systemd does this automatically as part of mounting the tmpfs. (See mount_one() in src/shared/mount-setup.c.)
/sys/fs/cgroup does not need to be created, as the kernel (sysfs) automatically provides the empty mountpoint; systemd only mounts the cgroupfs there.