How to mount and manage NFS shares on Linux Ubuntu

Table of Contents

Case #

This article provides a step-by-step procedure on how to mount and manage NFS shares on Linux Ubuntu.

Solution #

To mount and manage NFS shares on Linux Ubuntu, follow the step-by-step procedure outlined below.

  1. Install NFS client packages.
sudo apt update
sudo apt install nfs-common

Create a directory to serve as the mount point for the NFS share:

sudo mkdir /mnt/nfs_share

Mount the NFS share to the specified directory:

sudo mount <NFS_server_IP_address>:<NFS_share_directory> /mnt/nfs_share

Replace <NFS_server_IP_address> with the IP address of the NFS server and <NFS_share_directory> with the directory path on the server you want to mount.

For example:

sudo mount 192.168.0.100:/data/share /mnt/nfs_share

Verify the NFS share is mounted successfully:

df -h

This command will display the mounted file systems, and you should see the NFS share listed.

Make the NFS share mount automatically at system startup: Edit the /etc/fstab file using a text editor such as nano or vim:

sudo nano /etc/fstab

Add the following line at the end of the file:

<NFS_server_IP_address>:<NFS_share_directory> /mnt/nfs_share nfs defaults 0 0

Replace <NFS_server_IP_address> with the IP address of the NFS server and <NFS_share_directory> with the directory path on the server you want to mount.

For example:

192.168.0.100:/data/share /mnt/nfs_share nfs defaults 0 0

Save the changes and exit the text editor.

Unmount the NFS share:

sudo umount /mnt/nfs_share

Remount all file systems listed in /etc/fstab:

sudo mount -a

Manage the NFS share files as you would with any other files on the local system using standard Linux commands like ls, cp, and mv. Remember to replace <NFS_server_IP_address> and <NFS_share_directory> in the above bash commands with the appropriate values for your NFS server and share. Additionally, ensure you have the necessary permissions and access to the NFS server and share before attempting to mount them.

Powered by BetterDocs