How to Specify the Order in Which Filesystems are Automatically Mounted

fstabmount

I need a particular row in /etc/fstab to be mounted always after two other rows:

# Always mount these first
UUID=fdf38dd4-9e9d-479d-b830-2a6989958503 / ext4 noatime,discard,errors=remount-ro 0 1
UUID=2b548eb8-fa67-46ce-a998-91d587dba62f /home/.hdd ext4 errors=remount-ro 0 2

# Always mount this second
none /home/ak aufs br:/home/.ssd/ak=rw:/home/.hdd/ak=rw 0 0

The current behavior is to often reverse the order of the last two rows in an unpredictable manner. How can I specify the necessary order?

Best Answer

Systemd has now included a dependency option that enforces mount ordering. In your case add the fstab arguments:

x-systemd.requires-mounts-for=/,x-systemd.requires-mounts-for=/home/.hdd

The noauto option will not work if you need to mount over other mounted file systems. In my case the above worked see commit https://github.com/systemd/systemd/commit/3519d230c8bafe834b2dac26ace49fcfba139823 for more details.

Related Question