How to mount NFS server with autofs

This is a simple and quick Howto on setting up reasonably secure NFS file server and clients in a home network and dynamically mounting NFS shares with autofs. Basic openSUSE Linux and networking knowledge is assumed.

Required packages: nfs-kernel-server, nfs-client, yast2-nfs-server, yast2-nfs-client, autofs

NFS server:

  1. Assign server IP, eg. 192.168.1.2
  2. Create folder to share, eg. /mnt/ServerData, with rwxrwx— permissions
  3. Create new user group, eg. dataserver, GID 1000
  4. Create new user, eg. datauser, UID 1000 (optional, can be your own user name, but remember your UID)
  5. YAST -> Network Services -> NFS Server
  • NFS Server - Start
  • Firewall - Open Port in Firewall
  • Enable NFSv4
  • Enter NFSv4 Domain Name: localdomain
  1. Next
  2. Directories to Export
  • Add Directory - /mnt/ServerData
  • Add Host
  • Host Wild Card: 192.168.1.3 (must be same as client IP or use wildcard * to allow all hots)
  • Options: fsid=0,crossmnt,rw,root_squash,sync,no_subtree_check
  1. Finish
  2. YAST -> System -> System Services (Runlevel)
  • Check that nfs server and rpcbind are running

NFS client:

  1. Assign client IP, eg 192.168.1.3 (must be same as set in server)
  2. Create new user group, eg. dataserver, GID 1000 (name and GID must be same as set in server)
  3. Create new user, eg. datauser, UID 1000 (name and UID must be same as set in server, optional, or can be your own user name, simply add your user name to usergroup dataserver)
  4. YAST -> Network Services -> NFS Client -> NFS Settings
  • Enable NFSv4
  • NFSv4 Domain Name: localdomain
  • Open Port in Firewall
  1. OK
  2. YAST -> System -> System Services (Runlevel)
  • Check that autofs, nfs and rpcbind are running
  1. Dolphin -> Places
  • Add Entry
  • Description: NFS Server
  • Location: /mnt/DataServer (do NOT create any folders in /mnt, autofs will do this dynamically)

Autofs:

  1. Open and edit file /etc/auto.master
  • Add this line: /mnt/DataServer /etc/auto.misc --timeout 10
  1. Open and edit file /etc/auto.misc
  • Add this line: Data -fstype=nfs,rw,soft,intr,nosuid,nodev,tcp,retry=10,rsize=32768,wsize=32768 192.168.1.2:/
  1. Restart autofs in shell: /etc/init.d/autofs restart

Now, open Dolphin and click on Places -> NFS Server - it should mount the server export folder automatically.

For more info, check this article: Quick HOWTO : Ch29 : Remote Disk Access with NFS - Linux Home Networking

I found your post linked from your article about the Seagate BlackArmor NAS. Fortunately I have a Thecus which is Linux based and works much better. Thanks for this post, you spurred me to finally get around to grokking autofs.

I already had NFS setup and could mount manually or at boot, but I didn’t like the idea of a down NAS blocking boot, so autofs was what I wanted.

I tried the autofs setup from Yast2 (you have to install yast2-autofs) but it kept asking for a proper LDAP setup so I gave up and edited /etc/auto.master directly. Basically I did this:

/etc/auto.master:
[existing lines]
/nas /etc/auto.nas

I didn’t fill the third field. I let the timeout default to 10 minutes, I think 10 seconds is too short.

/etc/auto.nas:
Movie           -rw                     nas:/raid/Movie

nas is the non-FQDN of my NAS box, very imaginative name I know, but I don’t think I need more than one NAS box at the moment. Then I did:

ln -s /nas/Movie /home/Movie

Restart autofs with rcautofs reload, and voila, when I access /home/Movie it gets automounted.

That’s all.

Cheers ken_yap. This is what I’ve been working around as well.

searching a solution for an opposite way of handling the autofs and NFS / Samba
I stumbled over this thread…
I would like to knwo were I can disable it
I want to STOP autofs
It keeps my QNAP NAS alive 24:7

this was not so with 11.4 Opensuse

OR? is it another issue I should take a look at

could you please advise me and point me towards the relevant subtopic
or should this be a new question ?
ciao