Slackware trying to mount NFS shares before the network is ready
I have a right pain of a problem in this network in that individual machines are slow to get network access at boot. I haven’t had the opportunity to properly find out why, but my instinct says the blame lies with the Allied Telesyn switches.
The big problem this causes is that any machines with a remote filesystem, such as an NFS share, in their fstab fail to mount the shares at boot; which means I have to manually ssh in and issue a mount command as root.
The solution is to ask rc.inet2 if it would kindly consider waiting just a little longer for the network to come up and not mount remote filesystems if it doesn’t.
The following patch attempts to ping an always-on host, preferably the host that serves the filesystem(s) you are going to mount.
- If a response is received, the boot process continues as normal.
- If there’s no response to the first ping:
- A further 5 pings are attempted.
- A countdown is displayed.
- After 6 failed attempts boot continues, but with no attempt to mount remote filesystems.
rc.inet2.diff (download rc.inet2.diff.gz):
+++ ./rc.inet2 2010-06-14 14:05:24.237107265 +0100
@@ -15,9 +15,16 @@
# At this point, we are ready to talk to The World...
+lan_test_host="<known up host, or remote filesystem server>";
+avail=6;
+while ! ping -c1 $lan_test_host &>/dev/null && (( avail-- > 1 ));
+do
+ echo "Waiting for network before mounting remote filesystems... $avail";
+ sleep 1;
+done
# Mount remote (NFS) filesystems:
-if cat /etc/fstab | grep -v '^#' | grep -w nfs 1> /dev/null 2> /dev/null ; then
+if cat /etc/fstab | grep -v '^#' | grep -w nfs 1> /dev/null 2> /dev/null && ((avail)); then
# Start rpc.portmap, /sbin/rpc.lockd, and /sbin/rpc.statd if we find NFS
# volumes defined in /etc/fstab since these will need to be running in order
# to mount them. If they are not running, attempting to mount an NFS
@@ -46,7 +53,7 @@
# Mount remote CIFS filesystems. Note that where possible, using CIFS is
# preferred over SMBFS. SMBFS is no longer actively maintained.
-if cat /etc/fstab | grep -v '^#' | grep -w cifs 1> /dev/null 2> /dev/null ; then
+if cat /etc/fstab | grep -v '^#' | grep -w cifs 1> /dev/null 2> /dev/null && ((avail)); then
echo "Mounting remote CIFS file systems: /sbin/mount -a -t cifs"
/sbin/mount -a -t cifs
# Show the mounted volumes:
@@ -54,7 +61,7 @@
fi
# Mount remote SMB filesystems:
-if cat /etc/fstab | grep -v '^#' | grep -w smbfs 1> /dev/null 2> /dev/null ; then
+if cat /etc/fstab | grep -v '^#' | grep -w smbfs 1> /dev/null 2> /dev/null && ((avail)); then
echo "Mounting remote SMBFS file systems: /sbin/mount -a -t smbfs"
/sbin/mount -a -t smbfs
# Show the mounted volumes:
In order to apply the above patch, do the following as root:
# wget http://blog.tpa.me.uk/wp-content/uploads/2010/06/rc.inet2.diff.gz
# zcat rc.inet2.diff.gz | patch -p1
Do not forget to manually edit your newly patched file to replace “<known up host, or remote filesystem server>” with a valid hostname or IP address.

Hi,
I run the UK version of system administrator appreciation day website.
Would it be OK if I link to your blog or maybe include your newest story as a feed?
Anyway I enjoyed reading your site.
Let me know if you have any comments about sysadminday.co.uk.
Thanks
@Ferrgle
Sure, no problem.
I worked at a university that chose to purchase Allied-Telesyn switches instead of Cisco. Bad decision IMHO, though that is another story. Your problem may be caused by spanning-tree protocol (STP). I am unsure, if it is enabled by default on AT switches. Most companies don’t enable it by default, though Cisco does. Not sure how much you know about STP. By default a switch port will not move into forwarding mode for at least 30 seconds and possibly 50 seconds, once it becomes active (ie a PC powers up). Cisco developed a feature called portfast to alleviate this issue.
If the switches are running stp, you could disable it. This would of course open the network up to switching loops. Another possibility is to use Rapid STP (RSTP), which will move a switch port into forwarding within 10 seconds or less. It sounds like the AT switches are using the older version of STP.
HTH
G’Day
Have you tried adding the _netdev option to the fstab entries? The underscore is not a typo. This option tells the system to wait for networking before attempting to mount a filesystem. It is particularly handy for iSCSI volumes.