I mount successively two points using fstab in my linux system

# Mounting apps drive
UUID=c54ca7da-117d-4cb2-8897-019ba4f6f12d /media/user/apps ext4 defaults 0 2
# Mounting opt based on apps mountpoint
/media/user/apps/opt /opt none bind

As you can see, the second mountpoint /opt is mounted on the previous mounted partition /media/user/apps/. I am not sure, whether it is safe to do like that. I am asking, if I should add some kind of condition or waiting time before I mount /opt. If the first fstab command is not yet completed and then the second command tries to bind there might be a problem, is that right?

1 Answer 1

/media/user/apps/opt /opt none bind,x-systemd.requires=/media/user/apps

Should do the trick.

There are two more options that help doing a safe successive mounting, because when we need to specify order dependencies between mount commands and other units.

  • x-systemd.after
  • x-systemd.before

So we can add

/media/user/apps/opt /opt none bind,x-systemd.after=/media/user/apps

But also, equivalently,

UUID=c54ca7da-117d-4cb2-8897-019ba4f6f12d /media/user/apps ext4 defaults,x-systemd.before=/opt 0 2

More information at systemd.mount


You must log in to answer this question.

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