Gentoo Wiki



You have a notebook setup which mounts some directories from a local net-only server, e.g. mp3s, portage dir, etc. When you're travelling, mounting those nfs directories will fail as the nfs host is not reachable. This will result in several minutes of hang time during the boot process. This tip tries to avoid that long wait.

The idea

I wrote a mount helper script that checks if the host is up and running before mounting it. See man mount for further information on mount helper.

File: /sbin/mount.nfs

REMOTE_HOST=`echo "$@"|gawk -F ":" '{print $1}'`
ping -c1 -W1 ${REMOTE_HOST} > /dev/null
if [ $PING_RESULT -eq 0 ]
        mount -t nfs -i "$@"
        echo "Error: ${REMOTE_HOST} is not reachable"

Why it (should) work

I'm using only programs from the root filesystem (those in /bin an /sbin) so this works even if you mount /usr via nfs. What is does is simply that it pings the remote host. If it's not reachable (PING_RESULT != 0 (==1)) it prints an error message. If it succceeds it will start the mount process. The parameter "-i" for the mount command tells mount not to start /sbin/mount.nfs again. This script gave me a HUGE speed up when I'm not running my notebook at home but on travel. I hope you'll enjoy it. Feel free to extend it further.

Retrieved from ""

Last modified: Fri, 05 Sep 2008 23:33:00 +0000 Hits: 6,507