I have one network share that I mount in fstab. This is working fine.
Then, I have a second mount which binds on the folder from the first mount. Something like this:
//my-cifs-share/foo /mnt/foo-share cifs _netdev,dir_mode=0777 0 0
/mnt/foo-share /my/binded/folder none bind
Now, my problem is that apparently the second mount is executed before the first mount. Hence, the folder /my/binded/folder will empty after boot. When I then log in and execute mount -a
just once, it gets created all fine.
So, is there any way to enforce the order or to make one mount depended on another one?
Thanks a lot!
//edit: As discussed in the comments there seems to be no real save path. Hence I decided to go with this: Leave fstab as it is above. Use crontab to run mount -a
every 5 minutes. Seems to be good enough for now.
from man mount:
I think your distro uses this parameter as default on boot. Try to find and remove it. (I don't know redhat)
Avoid defining static bind mounts to directories that reside on filesystems that aren't "guaranteed" to exist. You're bound to run into multiple problems as time goes on, and this is only one example. Consider what happens when this CIFS mount inevitably drops during operation.
In most situations, this kind of scenario is better suited to a symbolic link than a bind mount. Symlinks handle their target dropping gracefully by becoming a "broken" link until the target is restored. Is there some reason you can't use a symlink for this?