Setting Up Standard Linux File Systems and Configuring NFSv4 Server
NFSv4 is a file-sharing IETF standard for the Network File System. The NFSv4 working group is tasked with maintaining the current NFSv4.0, NFSv4.1, and NFSv4.2 protocols as well as the specifications of relevant ONC components, such as those defining RPC, XDR, and RPCSECGSS, in order to preserve the usefulness and currency of NFS Version 4. The RDMA protocols that were created by the now-defunct RDDP WG (RFCs 5040-5045, e.g., RDMAP, DDP, and MPA) and whose maintenance and extension was formerly handled by the now-defunct STORM WG are likewise maintained and extended by the NFSv4 working group.
Extensions will also be created when needed to address issues with the protocols as they are now stated, to support appropriate file system semantics, and to keep up with technological advancements in the networking field.
Setting Up Standard Linux File Systems and Configuring NFSv4 Server
Follow the below steps to Set up Standard Linux File Systems and Configuring NFSv4 Server:
Step 1: Installing the NFS server:
The NFS server package provides user-space support needed to run the NFS kernel server. To install the package, run:
Step 2: NFS services will begin immediately when installation is complete.
NFS version 2 is not enabled in Ubuntu 20.04. Both versions 3 and 4 can be used. By using the cat command listed below, you can confirm that:
$ sudo cat /proc/fs/nfsd/versions
Step 3: Configuring an NFSv4 server
Make sure the idmapd daemon is running and configured before we start. To construct an NFSv4 server, this service handles the translation of NFSv4 names (user@mydomain) to user and group IDs.
NEED_IDMAPD=YES
Step 4: Make the file systems
The exported directories are relative to the global root directory that the NFSv4 server uses. You may connect the folders you want to export to the share mount point using bind mounts.
The root directory and the share mount points must first be created:
$ sudo mkdir -p /srv/nfs4/backups $ sudo mkdir -p /srv/nfs4/www
Step 5: Bind the directories to the share mount points by doing the following:
$ sudo mount --bind /opt/backups /srv/nfs4/backups $ sudo mount --bind /var/www /srv/nfs4/www
Step 6: Restart NFS service
We need to restart the NFS service after making changes to the configuration file:
$ service nfs-kernel-server restart [sysvinit / upstart based system] $ systemctl restart nfs-server [systemd based systems]
Step 7: Exporting Network Shares
The command below is to view the network shares that are accessible on an NFS server.
$ showmount -e 192.168.0.1
Step 8: Using autofs to mount exported NFS shares
Edit your /etc/auto.master as follows:
/media/nfs /etc/auto.nfs-share --timeout=60
Step 9: Create a map file
writeable_share -fstype=nfs4 192.168.0.12:/ non_writeable_share -fstype=nfs4 192.168.0.12:/mydir
Step 10: Booting up
Lastly, issue the following command to make autofs start when the computer boots up:
# chkconfig --level 345 autofs on # systemctl enable autofs [systemd based systems]
Conclusion:
We hope this post served as a helpful guide for you as you set up and configured an NFS server suitable for your environment. For more assistance, you might also wish to consult the respective man pages (man exports and man idmapd. conf, for example).