This is an old revision of the document!
NFS
There are a lot of resources online for NFS (Network File System). Nevertheless I decided to place my notes here to help me with my configuration, as there are a number of nuances that such notes will potentially assist with in the future. Sadly a number of resources I use seem out of date, not updated and/or possible subject to disappearance.
Links
The following are some helpful links:
- Ubuntu Help NFSv4Howto
- Ubuntu community SettingUpNFSHowTo
- Havetheknowhow.com How to configure NFS Version 4 (NFS4) on Ubuntu Server
- die.net exports(5) - Linux man page
Some other interesting nfs related commands:
mountstats
give client side nfs operation statisticsshowmount
Shows the clients (IP addresses) mounted to the nfs servernfsstat
Shows some nfs server server statistics
—-
NFS Server
sudo apt install nfs-kernel-server
to install- Create share directories on host
sudo mkdir -p /export/storage
(-p also creates higher level directories if necessary.)
sudo vim /etc/exports
- edit the exports file as required
# /etc/exports: the access control list for filesystems which may be exported /export 192.168.1.0/24(insecure,no_subtree_check,rw,nohide,fsid=0) #/export/Disk1 192.168.1.0/24(insecure,no_subtree_check,rw,nohide) #/export/Disk2 192.168.1.0/24(insecure,no_subtree_check,rw,nohide) /export/Disk4 192.168.1.0/24(insecure,no_subtree_check,rw,nohide) /export/shared 192.168.1.0/24(insecure,no_root_squash,no_subtree_check,rw,nohide) /export/storage 192.168.1.0/24(insecure,no_subtree_check,rw,nohide,fsid=1)
- As the /export/storage is using mergerfs it needed to be given a separate fsid. (The fsid can just be a unique assigned integer.)
- /export/Disk1 and /export/Disk2 have been commented out as they are form /export/storage using mergerfs.
Adjust the sudo vim /etc/fstab
file to allow for boot setup of nfs export mount points.
#<file system> <mount point> <type> <options> <dump> <pass> UUID=d426f5e0-7fbd-4e7f-915e-b7c78eb70877 / ext4 errors=remount-ro 0 1 UUID=e3442da3-4eaf-477d-94af-6ace66097a54 none swap sw 0 0 UUID=2fedae7e-8214-4fec-a6dd-85d7026d474f /media/Disk1 ext4 defaults 0 0 UUID=38f52a66-fe96-4eb4-a794-6fe1d02bab4a /media/Disk2 ext4 defaults 0 0 UUID=1cb1509c-ec09-46cd-ab30-23f3be5b554e /media/Disk3 ext4 defaults 0 0 UUID=2ba18a1e-d48d-4122-bff8-30c2bc359749 /media/Disk4 ext4 defaults 0 0 /media/Disk1:/media/Disk2 /srv/storage fuse.mergerfs use_ino,defaults,allow_other,minfreespace=50G,fsname=mergerfs 0 0 #/media/Disk1 /export/Disk1 bind bind 0 0 #/media/Disk2 /export/Disk2 bind bind 0 0 /srv/storage /export/storage bind bind 0 0 /media/Disk4 /export/Disk4 bind bind 0 0 /home/shared /export/shared bind bind 0 0
The base server configurations options are given in: sudo vim /etc/default/nfs-kernel-server
. However the current base options meet our needs and do not need to be modified.
To apply configuration changes sudo systemctl restart nfs-server.service
NFS Client
sudo apt install nfs-common
to install the nfs client
To apply configuration changes sudo systemctl restart nfs-client.target
The base client configurations options are given in: sudo vim /etc/default/nfs-common
. However the current base options meet our needs and do not need to be modified.
- NEED_STATD=no :(default) we do not need to change the standard port number used
- NEED_GSSD=no :(default) we do not use kerebos security
- NEED_IDMAPD=no:(default) we do not need to map gid and uid with names
Mounting the nfs client manually:
sudo mount -t nfs -o rw,vers=4 192.168.1.5:/export/storage /mnt/storage
to mount just the specific directory.sudo mount -t nfs -o rw,vers=4 192.168.1.5:/export /mnt
to mount all the defined exports.sudo unmount /mnt/storage
to unmount
Check status of clients:
findmnt
to list file system in tree format orfindmnt -l
in flat list.
To allow automatic boot of nfs clients: sudo vim /etc/fstab
192.168.1.5:/export /mnt nfs4 bg 0 0