{{tag>linux debian nfs fstab server}} ======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 [[https://help.ubuntu.com/community/NFSv4Howto|NFSv4Howto]] *[[http://www.troubleshooters.com/linux/nfs.htm|Troubleshooters NFS: Overview and Gotchas]] *Ubuntu community [[https://help.ubuntu.com/community/SettingUpNFSHowTo|SettingUpNFSHowTo]] *Havetheknowhow.com [[http://www.havetheknowhow.com/Configure-the-server/Configure-NFS.html|How to configure NFS Version 4 (NFS4) on Ubuntu Server]] *die.net [[https://linux.die.net/man/5/exports|exports(5) - Linux man page]] *[[https://www.golinuxcloud.com/unix-linux-nfs-mount-options-example/|NFS mount options | NFS exports options | Beginners Guide]] *[[https://www.quora.com/What-are-the-differences-between-bind-mounts-and-symlink-on-Unix|What is a bind mount?]] *[[https://www.quora.com/What-are-the-differences-between-bind-mounts-and-symlink-on-Unix|What are the differences between bind mounts and symlink on Unix?]] Some other interesting nfs related commands: * ''mountstats'' give client side nfs operation statistics * ''showmount'' Shows the clients (IP addresses) mounted to the nfs server * ''nfsstat'' 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. # 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:/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 or ''findmnt -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 ---- <- home_server:home_server_setup:other_services:disk|Prev ^ home_server:home_server_setup:other_services:index|Start page ^ home_server:home_server_setup:other_services:rsync|Next ->