Linux · 2月 6, 2023 0

How to set up a NFS server share on Linux


NFS (Network File System) is available for Linux systems and makes the job extremely easy. Since NFS is built directly into the Linux kernel, it is both powerful and available on every Linux distro.

How to configure an NFS server share on Linux.

How to Set up NFS server

The first thing that we need to do is install the NFS server package.

$ sudo apt install nfs-kernel-server


$ sudo dnf install nfs-utils

Next, ensure that the NFS service is running and will start automatically.

$ sudo systemctl enable --now nfs-server

we’ll store our NFS share as /media/nfs.

$ sudo mkdir -p /media/nfs

Next, we will edit the /etc/exports file.

$ sudo nano /etc/exports

Each share gets its own line in the file. Across from that, you can list the hostname of an accepted client, if is available in the server’s hosts file.


You can include as many shares as you like, provided each has its own line for comparison. You can also include more than one hostname or IP in each line and assign them different permissions.


Your share is now accessible from the client machines that you configured in your /etc/exports file.

How to Connect to NFS server from client

First thing we have to do is install the appropriate NFS packages on our system.

$ sudo apt install nfs-common


$ sudo dnf install nfs-utils

The NFS share(s) will be available with the package installed. So, to try it out, pick a directory to mount to, and run the mount command as root privileges .

$ sudo mount -t nfs4 /media/share

Your NFS server is now ready to start serving files.

%d 博主赞过: