Connecting to NFS shares after wireless connects

Asked by MyD0j0 on 2012-03-02

I have a laptop running Ubuntu 11.10 desktop and server. On the server I have several NFSv4 shares that my laptop can connect to manually (music, pics, movies and a location for backups). Since I am connecting to the network using wireless, I understand that I cannot use fstab to automatically mount the NFS shares at boot time.

I have tried using autofs for accessing these shares, but have had no luck in getting the shares to mount.

root@MasterD0j0:~# automount -f -v
Starting automounter version 5.0.6, master map /etc/auto.master
using kernel protocol version 5.02
mounted indirect on /mnt/CentralD0j0 with timeout 300, freq 75 seconds
mounted indirect on /mnt/Eric with timeout 300, freq 75 seconds

/mnt/CentralD0j0 /etc/
/mnt/Eric /etc/auto.eric
/mnt/CentralD0j0 -rw,fstype=nfs4 CentralD0j0:BigDisk/MultiMedia

/mnt/Eric -rw,fstype=nfs4 CentralD0j0:BigDisk/NetUsers/Eric

# Do you want to start the idmapd daemon? It is only needed for NFSv4.

# Do you want to start the gssd daemon? It is required for Kerberos mounts.

this is what i use to manually mount the shares
mount -t nfs4 -o proto=tcp,port=2049 /mnt/CentralD0j0
mount -t nfs4 -o proto=tcp,port=2049 /mnt/Eric

If someone can't tell me what I'm doing wrong with the autofs configs, can someone point me in the direction of an alternative means of automatically connecting to my shares (after the wireless is enabled) when I login to my desktop?

I appreciate the help!


Question information

English Edit question
Ubuntu gnome-nettool Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:


gksudo gedit /usr/bin/mountmynfs; sudo chmod +x /usr/bin/mountmynfs

Add these 3 lines:

sleep 30
mount -t nfs4 -o proto=tcp,port=2049 /mnt/CentralD0j0
mount -t nfs4 -o proto=tcp,port=2049 /mnt/Eric

Save the new file and close gedit, then run:

gksudo gedit /etc/rc.local

and ABOVE the exit 0 line add:

mountmynfs &

The ampersand is important. This will make the script run as root (needed for mounts which users cannot do at CLI) but if the script is not backgrounded (which is what the ampersand does) then it will simply delay the boot 30 seconds and nothing more. By backgrounding the script, it gives the OS enough time to get loaded and network manager to do it's thing. If the sleep is not long enogh, simply edit the value.

MyD0j0 (myd0j0) said : #2

Thanks actionparsnip, that solved my question.

MyD0j0 (myd0j0) said : #3

that was brilliant, actionparsnip!

works after a suspend and hibernation as well as after a normal boot. So simple--why isn't THAT in the NFS/SAMBA documentation for Ubuntu?!?!