In my situation I need to ensure one particular filesystem is mounted before a few subsequent filesystems should be. In this case, for example, I want to mount a USB disk before bind mounting some other directories on it.
I am comfortable enough to write an init script to accomplish this, however before doing that I would like to know if there might be a more prudent or common solution to this problem--I'm skeptical that this problem is a rare one.
Do you want it only to happen at system start up? If not you could maybe do something with automount, along the lines of an executable map which checks to see if the USB device is available and if so makes the dependent locations available for mounting.
Something like:
auto.magic:
auto.master:
You'll need to do a service autofs (re)start.
Then when you do ls /magic/films, automount will call your script and mount the film share if /media/usb is available.
What distribution are you using?
I'm quite sure that either the init scripts mount filesystems one by one top to bottom in
/etc/fstab
or look for dependencies.Either way I never had any problems with mountpoints residing in other mount points and use them extensively, together with
mount --bind
.On the other hand, when the mount point doesn't exist,
mount
will print an error and init scripts go on (as long as the mount point is set as non critical by setting0
in last column in/etc/fstab
)