Open In App

Setting Up Standard Linux File Systems and Configuring NFSv4 Server

Last Updated : 09 Jan, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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:

$ sudo apt update
$ sudo apt install nfs-kernel-server
Installing NFS Server

 

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
Confirming that NFS Version 2 is not enabled

 

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
Checking idmapd daemon is running

 

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
Making the File Systems

 

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
Binding the directories

 

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]
Restarting NFS service

 

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
Exporting Network shares

 

Step 8: Using autofs to mount exported NFS shares

Edit your /etc/auto.master as follows:

/media/nfs /etc/auto.nfs-share --timeout=60
Mount exported NFS shares

 

Step 9: Create a map file

writeable_share  -fstype=nfs4 192.168.0.12:/
non_writeable_share  -fstype=nfs4 192.168.0.12:/mydir
creating map file

 

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]
Booting

 

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).



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads