On Thu, 17 May 2012 10:52:15 -0500 (CDT) Matthew J. Roth wrote:
Do you mind sharing that script? It's a great idea for solving a common problem.
This will probably get mangled due to a few long lines, but I'll give it a shot.
In the /etc/rc.d/rc.local script I have this line:
/usr/local/bin/bg-mount-nfs
That /usr/local/bin/bg-mount-nfs script looks like:
#!/bin/bash # # Background mounts for each of the nfs filesystems appearing in # /etc/fstab not marked as noauto # PATH="/sbin:/usr/sbin:/bin:/usr/bin" export PATH sed -e '/^#/d' -e 's/[ \t][ \t]*/\t/g' /etc/fstab | grep -w nfs | grep -w -v noauto | cut -f2 | while read mountpoint do nohup /usr/local/bin/mount-filesystem "$mountpoint" > /dev/null 2>&1 < /dev/null & done
And the /usr/local/bin/mount-filesystem script it backgrounds for each filesystem looks like:
#!/bin/bash # # Argument is a mountpoint, keep trying to mount the thing till # it appears in /proc/mounts. # PATH="/sbin:/usr/sbin:/bin:/usr/bin" export PATH if [ -z "$1" ] then echo Hey! Missing mountpoint argument! 1>&2 exit 2 fi check=`sed -e '/^#/d' -e 's/[ \t][ \t]*/\t/g' /etc/fstab | cut -f2 | fgrep -x "$1"` if [ "$check" = "$1" ] then : else echo "$1" does not appear as a mountpoint in /etc/fstab! 1>&2 exit 2 fi while true do check=`sed 's/[ \t][ \t]*/\t/g' /proc/mounts | cut -f2 | fgrep -x "$1"` if [ "$check" = "$1" ] then exit 0 fi if mount "$1" -o fg then : else sleep 10 fi done