Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

The standard way to setup a central "/home" directory on a Linux workstation is using NFS. The problem is that I don't like the lack of real security in NFS. So instead I want to try to use SSHFS. SSHFS in-and-of itself works fine, the problem is with mounting it at boot. If I add a line to "/etc/fstab" for the SSHFS share, the workstation complains that it can't contact the SSH server. This is true because the "/etc/fstab" lines are executed before networking is actually up!

Right now I am using the following init script to mount "/home":

#!/bin/sh

# Mounts "/home"  over SSHFS at boot

start () {
    while true; do
        ping -c 1 "10.0.0.200" 1> /dev/null

        if [ "$?" = 0 ]; then
            break
        fi

        sleep 1
    done

    sshfs root@10.0.0.200:/home/ /home/ -o transform_symlinks,allow_other,nonempty,hard_remove
}

case "$1" in
    start)
        start
        ;;

    *)
        echo "Usage: $0 {start}"
        exit 1

esac

Basically it pings the SSH server once per second until it can connect, then it mounts the SSHFS share.

My question is: Is there a more direct and less "hack-ish" way to make "/etc/fstab" wait until there is an active network connection before attempting to mount "/home"?

An alternative idea I had, was adding the "sshfs root@10.0.0.200:/home/ /home/ -o transform_symlinks,allow_other,nonempty,hard_remove" line as an "post-up" script in "/etc/network/interfaces", but that still feels wrong.

Environment:

Server OS: Ubuntu Server Edition 10.04

Client OS: Ubuntu Desktop 10.04

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You probably want to add the _netdev option to delay mounting until the network has been enabled:

sshfs#root@10.0.0.200:/home/ /home/ fuse transform_symlinks,allow_other,_netdev,nonempty,hard_remove 0 0

You can also put your script in /etc/network/if-up.d/ or the mount command in /etc/rc.local.

share|improve this answer
    
Adding "_netdev" absolutely fixed it! Thank you for both the answer and the quick response time. –  Kevin Soviero Nov 2 '11 at 4:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.