VOOZH about

URL: https://thenewstack.io/linux-create-and-connect-to-an-nfs-share/

⇱ Linux: Create and Connect to an NFS Share - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-09-21 08:00:23
Linux: Create and Connect to an NFS Share
tutorial,
Linux / Networking / Operations

Linux: Create and Connect to an NFS Share

If you need faster copy and write speeds than you're finding with Samba, NFS is a great option. Just remember that NFS isn't quite as flexible as Samba.
Sep 21st, 2024 8:00am by Jack Wallen
👁 Featued image for: Linux: Create and Connect to an NFS Share

NFS stands for Network File System and is yet another way to share directories over a network. NFS has been around since the mid-’80s, and although it’s not quite as easy to use as Samba, it’s still a valid protocol for sharing files and folders.

But why would you choose NFS instead of Samba? One of the biggest reasons is that NFS is considerably faster than Samba. This is especially true when sharing larger files. I’ve witnessed Samba shares drag to a painfully slow crawl for no apparent reason. With NFS, that’s far less likely to happen.

The two main downfalls of NFS are that it’s not quite as easy to use as Samba (which is why a lot of people opt to go the SMB route) and that it doesn’t include any means of access control. Because of that, only use NFS on machines and networks that you trust are secure. And if you need better performance for LAN-based sharing, NFS is a great option.

Let me show you how it’s done.

What You’ll Need

For this demonstration, you’ll need two Linux machines on the same LAN. It doesn’t matter what distribution you’re using (because the necessary NFS software is available from most standard repositories). You’ll also need a user with sudo privileges. I’ll demonstrate this on Pop!_OS and AlmaLinux server.

Time to dig in.

Installing the Necessary Packages

The first thing we’ll do is log into the machine that will be our server and install the required software with the command:

sudo dnf install nfs-utils -y

Next, head over to the client, and install the same package with:

sudo apt-get install nfs-common -y

Notice the different names of packages from the server to the client. Make sure to install the right software on the right OS.

Create an NFS Share

Next, we’re clear to create the NFS share. Back at the server, we’re going to create a directory in the root called nfs-share with the command:

sudo mkdir nfs-share

Change the permissions of the directory with:

sudo chmod -R 777 /nfs-share

Define the New Share

We now have to define the new share in the /etc/exports file. On the server, open that file for editing with the command:

sudo nano /etc/exports

The format of each entry is:

directory client_IP (permissions)

Let’s say you have the following details:

  • directory: /nfs-share
  • client_IP: 192.168.1.79
  • permissions: read/write

The entry for the above information would be:

/nfs_share 192.168.1.79(rw)

Save and close the file.

Start the NFS Server and Open the Firewall

On the server, let’s open the firewall so our clients have access to the share. This is accomplished with the following two commands:

sudo firewall-cmd --permanent --zone=public --add-service=nfs
sudo firewall-cmd --reload

It’s now time to start and enable the NFS service, which can be done with a single command:

sudo systemctl enable --now nfs-server

You can verify the server is running with:

systemctl status nfs-server

Add Some Test Files and Create a Client Directory

Back on the server, let’s add some test files with the command:

touch /nfs-share/{test1,test2,test3}

On the client machine, create a directory that will serve as the mount point for the share with the command:

mkdir ~/nfs_mount

You can place that directory anywhere you like (so long as your user has permission to access it).

Mount the Share

Let’s say our NFS server is at IP address 192.168.1.210. On the client machine, the share is mounted with the command:

sudo mount 192.168.1.210:/nfs-share ~/nfs_mount

The NFS share directory on the server should now be mounted to the NFS mount directory on the client. If you view the contents of the nfs_mount folder on your client, you should see that it contains the files test1, test2 and test3 (which you created on the server).

If you want to make the mounting of the NFS share easier, we can add an entry to fstab. Open the file on the client machine for editing with the command:

sudo nano /etc/fstab

At the bottom of the file, add the following (modifying it to match your configurations):

192.168.1.210:/nfs-share  /home/USER/nfs-mount nfs rw 0 0

Notice that you cannot use ~/ to indicate your home directory in fstab. Instead, use the full path to the mount directory.

Test the configuration with:

mount -a

If you receive no errors, you’re good to go. You can verify it works by restarting your client machine. The NFS share should automatically mount.

And that’s all there is to setting up a basic NFS share on Linux. If you need faster copy and write speeds than you’re finding with Samba, NFS is a great option. Just remember that NFS isn’t quite as flexible as Samba, so you won’t be integrating with Active Directory or sharing printers. As well, there are no file manager integrations for NFS, so any time you want to configure a new share or connect to an existing one, it’s all about the command line.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.