Ubuntu

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.

[code]
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
[/code]

auto.master
[code]
/mnt/CentralD0j0 /etc/auto.media
/mnt/Eric /etc/auto.eric
[/code]

auto.media
[code]
/mnt/CentralD0j0 -rw,fstype=nfs4 CentralD0j0:BigDisk/MultiMedia
[/code]

auto.eric
[code]
/mnt/Eric -rw,fstype=nfs4 CentralD0j0:BigDisk/NetUsers/Eric
[/code]

/etc/default/nfs-common
[code]
# Do you want to start the idmapd daemon? It is only needed for NFSv4.
NEED_IDMAPD=yes

# Do you want to start the gssd daemon? It is required for Kerberos mounts.
NEED_GSSD=no
[/code]

this is what i use to manually mount the shares
[code]
mount -t nfs4 -o proto=tcp,port=2049 192.168.1.100:BigDisk/MultiMedia /mnt/CentralD0j0
mount -t nfs4 -o proto=tcp,port=2049 192.168.1.100:BigDisk/NetUsers/Eric /mnt/Eric
[/code]

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!

eric

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gnome-nettool Edit question
Assignee:
No assignee Edit question
Solved by:
actionparsnip
Solved:
2012-03-04
Last query:
2012-03-04
Last reply:
2012-03-02

Run:

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

Add these 3 lines:

#!/bin/bash
sleep 30
mount -t nfs4 -o proto=tcp,port=2049 192.168.1.100:BigDisk/MultiMedia /mnt/CentralD0j0
mount -t nfs4 -o proto=tcp,port=2049 192.168.1.100:BigDisk/NetUsers/Eric /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?!?!