Sometimes I need to share files between computers without using a USB stick or cloud drive. That’s where NFS comes in handy. It stands for Network File System, and it lets one computer share a folder with others over a local network.
If that sounds complicated—don’t worry. Setting up NFS on CentOS, which is a type of Linux, is actually pretty simple once you know the steps. I’ll walk you through it like we’re in the same room, and I promise to explain anything that sounds techy.
When I first tried NFS, I had no idea what I was doing. But once I got it running, I wondered why I hadn’t used it earlier. It’s like turning your server into a giant shared folder that everyone in your network can use. Kind of like a fridge everyone can grab snacks from—just don’t eat the last slice of digital pizza.
What Is NFS, in Plain Words?
NFS is a system that lets one Linux machine share its files with others on the same network. Think of it like a big folder in one place that everyone can open, read, or even write into (if allowed).
Here’s how I like to think of it:
- NFS Server = the computer that shares its folder
- NFS Client = the computer that connects to the shared folder
This makes sharing files in homes, schools, or small offices really easy. No need to copy and paste everything by hand or email files to yourself.
When Should You Use NFS?
Let me be honest—NFS is not for everything. But it works great when:
- You need fast file sharing between Linux machines
- You want a simple way to share a folder
- You don’t want to mess with fancy tools or software
NFS is like a polite house guest. It knocks first (using ports), asks nicely to come in, and then shares the snacks (files) if you give permission.
What You’ll Need Before We Start
Let’s get ready. Here’s what you should have:
- A CentOS server (the one that will share the folder)
- One or more client machines (could also run CentOS or other Linux)
- Sudo or root access on the server
- A local network (home or office)
For this guide, I used CentOS 7, but the steps are mostly the same for CentOS 8.
Step 1: Install the NFS Server Package
First, you need to install the tools. Log into your CentOS server and run:
sudo yum install nfs-utils -y
This command installs the nfs-utils package. It includes everything the server needs to share folders.
After that, enable and start the NFS service:
sudo systemctl enable nfs-server
sudo systemctl start nfs-server
You just turned your computer into a sharing machine. Or as I like to call it, the “Neatly Filed Stuff” server.
Step 2: Create the Folder to Share
Now pick a folder to share. Or create one. I made a new one like this:
sudo mkdir -p /srv/nfs/shared
Then I gave it full access (for testing purposes):
sudo chown -R nobody:nobody /srv/nfs/shared
sudo chmod 777 /srv/nfs/shared
Later on, you can change permissions to make it more secure.
Step 3: Configure the Exports File
The NFS server needs to know which folders to share and who can access them. That’s done in the exports file.
Open it like this:
sudo nano /etc/exports
Then add this line:
/srv/nfs/shared 192.168.1.0/24(rw,sync,no_subtree_check)
Here’s what this line means:
/srv/nfs/shared
is the folder we’re sharing192.168.1.0/24
is the IP range allowed to connect (adjust for your network)rw
= read and writesync
= writes happen immediatelyno_subtree_check
= speeds up access
After saving the file, apply the changes:
sudo exportfs -a
Then restart the NFS service:
sudo systemctl restart nfs-server
Step 4: Allow NFS in the Firewall
CentOS uses firewalld to control network access. You’ll need to allow NFS traffic through.
Run these commands:
sudo firewall-cmd --permanent --add-service=nfs
sudo firewall-cmd --reload
Now your NFS server is ready to share files.
Step 5: Mount the NFS Share on the Client
Now switch to the client machine (the one that wants to access the shared folder).
First, install the NFS client package:
sudo yum install nfs-utils -y
Then create a folder to mount the share:
sudo mkdir -p /mnt/nfs_client
Now mount the share using:
sudo mount -t nfs 192.168.1.100:/srv/nfs/shared /mnt/nfs_client
Replace 192.168.1.100
with your server’s actual IP address.
If everything went well, you can now access the files from the shared folder just like any local files.
Want It to Mount at Boot?
If you want the NFS share to stay mounted after a reboot, add this line to /etc/fstab
on the client:
192.168.1.100:/srv/nfs/shared /mnt/nfs_client nfs defaults 0 0
Again, update the IP if needed.
Things I Learned the Hard Way
Not everything goes smoothly the first time. Here are a few tips from my own oops moments:
- Make sure both machines can ping each other. If not, check the network or firewall.
- Double-check your exports file for typos. Even a small mistake can cause it to fail.
- Use
showmount -e 192.168.1.100
on the client to see if the server is exporting shares.
NFS Pros and Cons (Keep It Real)
Like anything, NFS has its strengths and weak spots.
Pros:
- Fast file sharing over local networks
- Easy to set up on Linux
- No special software needed
Cons:
- Not encrypted by default (not great over the internet)
- Works best only with Linux machines
- Can be tricky to secure without extra steps
It’s kind of like a cookie jar: easy to open in your own kitchen, but maybe not something you want strangers poking into.
Useful NFS Commands
Keep these handy when you’re working with NFS:
exportfs -v
– Shows shared foldersexportfs -ra
– Re-exports all sharesshowmount -e [server-ip]
– Shows shares from a server
Sticky note idea: write them on paper and tape it to your fridge. Nerd art.
Why I Still Use NFS
I use NFS for one big reason: it just works. At home, I set it up so my Raspberry Pi can save videos to a shared folder on my CentOS server. It runs in the background quietly, kind of like a ninja but without the sword.
Would I use it for internet sharing? No. That’s not its thing. But for fast, simple file sharing across Linux machines in the same house or office, it’s perfect.
And let’s be honest—sometimes, having your own “file fridge” at home just feels cool.
Final Thoughts
Setting up an NFS server on CentOS isn’t rocket science. It’s more like file science—neatly organized, shared, and easy to grab.
So now that your NFS is ready, what are you going to share? Music, backups, secret cat memes? The digital world is your oyster. Just make sure your firewall isn’t a clam.