How to Install NFS Server and Client on Ubuntu 22.04

What is NFS?


NFS stands for Network File System. It is a distributed file system protocol that allows users to access files and directories located on remote computers as if they were local. NFS is a popular file sharing protocol that is used in many different operating systems, including Linux, Unix, and Windows.

Here are some of the benefits of using NFS:

  • Centralized data storage: NFS allows you to store files on a central server, which can make it easier to manage and access files.
  • Increased efficiency: NFS can improve the efficiency of file sharing by reducing the amount of data that needs to be transferred over the network.
  • Data security: NFS can be configured to provide secure access to files, which can help to protect your data from unauthorized access.
  • Scalability: NFS is scalable, so you can easily add more clients or servers to your network without having to make any changes to your file sharing infrastructure.

If you are looking for a way to share files and directories over a network, NFS is a good option to consider. It is a reliable and efficient file sharing protocol that is supported by many different operating systems.

Here are some of the common uses of NFS:

  • Sharing files between computers on a local network
  • Sharing files between computers on a wide area network (WAN)
  • Providing file access to remote users
  • Storing backup data
  • Hosting web content

Install NFS Server and Client on Ubuntu 22.04

Step 1: Update the system packages

Run the following command in the terminal:

sudo apt update

Step 2: Install the NFS server

Run the following command:

sudo apt install nfs-kernel-server

Step 3: Create a shared directory on the server

Run the following command:

sudo mkdir /shared

Step 4: Change the ownership of the shared directory to root

Run the following command:

sudo chown root /shared

Step 5: Set the permissions of the shared directory to 755

Run the following command:

sudo chmod 755 /shared

Step 6: Edit the NFS configuration file

The NFS configuration file is located at /etc/nfs/server.conf. Open this file in a text editor and add the following line:

/shared *(rw,sync,no_root_squash)

This line tells the NFS server to export the /shared directory to all clients

Step 7: Restart the NFS server. 

Run the following command to restart the NFS server:

sudo service nfs-kernel-server restart

Step 8: Install the NFS client on the client computer

Run the following command on the client computer:

sudo apt install nfs-common

Step 9: Create a mount point on the client computer

Run the following command on the client computer:

sudo mkdir /mnt/shared

Step 10: Mount the NFS share on the client computer

Run the following command on the client computer:

sudo mount 192.168.1.100:/shared /mnt/shared

Replace 192.168.1.100 with the IP address of the NFS server.

Verify that the NFS share is mounted. Run the following command on the client computer:

df -h

You should see the NFS share listed in the output of this command.

Once you have completed these steps, you will be able to access the shared directory on the NFS server from the client computer.

Here are some additional things to keep in mind:

  • The IP address of the NFS server must be accessible to the client computer.
  • The client computer must have the NFS client package installed.
  • The shared directory on the NFS server must have the correct permissions set.
  • The NFS share must be mounted on the client computer.

I hope this helps! Let me know if you have any other questions.

Knowledge Base Linux
Knowledge Base Linux

Kblinux is an abbreviation for the phrase "Knowledge Base Linux." The website shares instructional articles related to the Linux system. I hope my small blog will reach many people who share the same passion for Linux.

Articles: 40

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.