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:
- Assign server IP, eg. 192.168.1.2
- Create folder to share, eg. /mnt/ServerData, with rwxrwx— permissions
- Create new user group, eg. dataserver, GID 1000
- Create new user, eg. datauser, UID 1000 (optional, can be your own user name, but remember your UID)
- YAST -> Network Services -> NFS Server
- NFS Server - Start
- Firewall - Open Port in Firewall
- Enable NFSv4
- Enter NFSv4 Domain Name: localdomain
- Next
- 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
- Finish
- YAST -> System -> System Services (Runlevel)
- Check that nfs server and rpcbind are running
NFS client:
- Assign client IP, eg 192.168.1.3 (must be same as set in server)
- Create new user group, eg. dataserver, GID 1000 (name and GID must be same as set in server)
- 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)
- YAST -> Network Services -> NFS Client -> NFS Settings
- Enable NFSv4
- NFSv4 Domain Name: localdomain
- Open Port in Firewall
- OK
- YAST -> System -> System Services (Runlevel)
- Check that autofs, nfs and rpcbind are running
- Dolphin -> Places
- Add Entry
- Description: NFS Server
- Location: /mnt/DataServer (do NOT create any folders in /mnt, autofs will do this dynamically)
Autofs:
- Open and edit file /etc/auto.master
- Add this line: /mnt/DataServer /etc/auto.misc --timeout 10
- 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:/
- 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