OpenSUSE Leap 42: Install nfs-kernel-server for NFS server

This article will describe installing nfs-kernel-server for NFS server.

1 Install nfs-kernel-server

Install nfs-kernel-server package.

> sudo zypper -n in nfs-kernel-server
> sudo systemctl enable nfsserver
> for t in FW_CONFIGURATIONS_EXT FW_CONFIGURATIONS_DMZ FW_CONFIGURATIONS_INT; do
  sudo sed -e "s/^${t}=\"\(.*\)\"/${t}=\"\1 nfs-kernel-server\"/g" \
       -i /etc/sysconfig/SuSEfirewall2
done
> sudo systemctl restart SuSEfirewall2

Reboot system for starting nfs-kernel-server.

> sudo reboot

2 Export directory to NFS

/etc/exportfs is written exported directories to NFS.

> cat /etc/exports
<path> <ipaddr>(<option>)

Update exported directories to NFS.

> sudo exportfs -ra

2.1 Exported directory for nfsroot

  • no_root_squash will use UID and GID of client for file access by client.
  • If UID and GID is shared by LDAP, use no_root_squash.
  • If using nfsroot for booting root filesystem, use no_root_squash.
  • subtree_check checks if file access by client is inside exported directory. no_subtree_check disable this check for performance.
> cat /etc/exports
/srv/nfsroot 192.168.11.0/24(rw,sync,no_root_squash,no_subtree_check)
> sudo mkdir /srv/nfsroot
> sudo exportfs -ra

2.2 Exported directory for file sharing

  • root_squash uses nobody:nogroup for file access by client.
> cat /etc/exports
/srv/nfsshare *(rw,sync,root_squash,subtree_check)
> sudo mkdir /srv/nfsshare
> sudo chmod 777 /srv/nfsshare
> sudo exportfs -ra

3 Mount NFS

Mount NFS with mount.nfs.

> sudo zypper -n in nfs-client
> sudo mount -t nfs 127.0.0.1:/srv/nfsshare /mnt