2

I recently started using systemd in linux. On systemd mount, I have some observations:

  • mount unit file is generated with mount point name when there is an entry in /etc/fstab.

I also observed the two scenarios listed below:

Precondition: I have below entry in fstab:

/dev/sda3 /test_mount ext4 rw,acl,nobarrier,nodelalloc 0 0

(So test_mount.mount file is generated under /var/run/systemd/generator/ directory after reboot.)

  • Scenario 1: I deleted the entry from fstab and rebooted the machine. My expectation is test_mount.mount file should be deleted from /var/run/systemd/generator/ directory. But the file is not deleted and systemd is attempting to mount the device node.

  • Scenario 2: I modified the entry in fstab. I renamed the mountpoint to sec_test_mount and rebooted the machine. My expectation is test_mount.mount file should be deleted from /var/run/systemd/generator/ directory and sec_test_mount.mount file should be newly created. sec_test_mount.mount is newly created but test_mount.mount is not deleted. Both the mount files are trying to mount and mount has happened twice.

0

systemd-fstab-generator creates the mount units under /run, because that filesystem is a tmpfs (in-memory filesystem), which is not preserved across reboots, so it's expected to be replaced with an empty volume on every boot.

(/var/run is supposed to be a symlink to /run, which is the tmpfs mount. That name exists for compatibility only, modern Linux uses /run directly everywhere.)

If that is not the case on your machine, I'd say that is where the problem is... If you fix that, the generator will properly recreate the mount units on every boot, since the tmpfs will be empty each time.

  • @filbranden Thank you very much for your reply. /var/run is symlink to /run but /run is not tmpfs mount in my system. – Arulananth Subramaniam Feb 8 at 2:24
  • I believe systemd will always mount /run automatically, so not sure why that is not happening correctly in your case... If you have an entry for /run in fstab, try removing that and rebooting to see if /run is now mounted correctly. Good luck! – filbranden Feb 8 at 4:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.