I have been living under the assumption that in Linux, filesystems are mounted solely based on the order in /etc/fstab. This is true only as long as they are the same filesystem type- local or network. I spent a good deal of time today revisiting the boot process and understanding the order of mounting in RHEL 6. And this post applies to RHEL 6 because I can’t say for sure for other distro or other RHELx without a close look but I am guessing it should be close to similar for pre-RHEL6 versions.
User wants to mount an NFS volume with a dependency on local lv. Thinking the order is what matters in fstab, I place it like this in fstab and reboot.
NAS:/vol/vol1 /vol1 /dev/mapper/vg1-lv1 /vol1/lv1
Voila! it doesn’t work. I work with Red Hat Support and the solution is to add _netdev option for the lv that depends on the NFS mount. In my defense, I was aware of _netdev but assumed it is for network file filesystems only.
The reason behind
When RHEL6 boots, init loads /etc/rc.sysinit which mounts all filesystems in fstab except nfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2,glusterfs and those with the _netdev option. Then the netfs service mounts all NFS filesystesm in fstab first and lastly those with _netdev last.
Extract from /etc/rc.sysinit:
mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2,glusterfs -O no_netdev
This will mount all (-a) entries in fstab but “exclude” those filesystem types appearing after “no” prefix (-t nonfs,nfs4…) and those with _netdev option (-O no_netdev). I spent a good amount of time reading “man mount” to decipher it.
Hence, the solution was to add _netdev option to the /vol1/lv1 in fstab which delays the mounting to /vol1/lv1 till NFS volumes are mounted.