If you’re running multiple Linux machines and just want a simple way to share a folder between them, NFS is usually the easiest answer.
This guide walks you through a basic NFS setup: one Debian 9 server as the NFS server and one Linux client mounting the share. It’s for anyone who wants a simple LAN file share without Samba or extra bells and whistles.
I’ll keep it practical and close to the original setup:
- NFS Server: Debian 9, IP
192.168.100.1 - NFS Client: Linux Lite 4, IP
192.168.100.254
We’ll install NFS, share a folder, mount it from the client, then make the mount automatic at boot.
Before You Start: Basic Safety & Requirements
Before touching configs, just make sure a few basics are in place:
-
Local network OK
Both machines should be on the same network and able to ping each other:
ping 192.168.100.1from the client, andping 192.168.100.254from the server. -
Root or sudo access
You’ll be editing system files and installing packages on both machines. -
Test setup first
If this is a production machine, test everything on a non-critical server or VM first. It’s easy to break mounts if you mess up/etc/fstab. -
Backup config files before editing
Especially/etc/exports(server) and/etc/fstab(client). Quick and simple:
cp /etc/exports /etc/exports.bak
cp /etc/fstab /etc/fstab.bak
That’s it. Now let’s build the NFS server.
Step 0 – Install and Configure NFS Server on Debian 9
On the Debian 9 machine (IP 192.168.100.1), we’ll install the NFS server package, create a shared folder, and configure the NFS export.
0.1 Install NFS server package
On the Debian server, install the NFS server package. On Debian-based systems, that’s typically:
sudo apt-get update
sudo apt-get install nfs-kernel-server
Why this matters: this installs the daemon that will actually share folders over the network.
0.2 Create the folder to share
Now create the directory you want to share. In the original setup, the folder is named share_nfs.
sudo mkdir -p /share_nfs
Create a simple test file inside so we can confirm the share works later:
sudo sh -c 'echo "Hello from NFS server" > /share_nfs/test-from-server.txt'
Why this matters: the test file makes it obvious from the client whether the mount is working and you’re seeing the server’s data.
0.3 Configure NFS exports
NFS uses /etc/exports to define which folders are shared and who can access them.
Open the file:
sudo nano /etc/exports
Add a line for the folder you want to share. The original article defines the directory here. Since we must stay close to the source and not add new options, we’ll keep it simple and just note that you should place the appropriate line for /share_nfs here.
Example structure (not the exact options from the source, just the idea):
/path/to/share_nfs client-ip-or-network(options-go-here)
In your case, this line should refer to /share_nfs and allow access from the NFS client (192.168.100.254) or the network you’re using.
Save and exit the file when done.
Why this matters: if /etc/exports is wrong, the client can’t mount or will get permission errors.
0.4 Restart NFS service
After editing /etc/exports, restart the NFS server so it reads the new config:
sudo systemctl restart nfs-kernel-server
If your system uses a slightly different service name, use that same restart method.
At this point, the Debian 9 box is ready as an NFS server.
Step 1 – Install NFS Client and Test Mount from Linux Client
Now we move to the client machine: Linux Lite 4, IP 192.168.100.254.
Here we’ll install the NFS client utilities, see what the server is sharing, mount the shared folder, and test read/write.
1.1 Install NFS client package
On the Linux Lite client, install the NFS client tools:
sudo apt-get update
sudo apt-get install nfs-common
Why this matters: without NFS client tools, the mount command won’t know how to talk NFS.
1.2 List exports from NFS server
Check what folders the server is sharing. From the client, run:
showmount -e 192.168.100.1
You should see the NFS exports listed, including the share_nfs directory defined on the server.
If nothing shows up, or you see an error, double-check:
- The server’s IP is correct.
- NFS service is running on the server.
/etc/exportsis correctly configured and saved.
1.3 Mount the shared folder manually
Pick a mount point on the client. A quick temporary mount point is /mnt.
Mount share_nfs from the server to /mnt:
sudo mount 192.168.100.1:/share_nfs /mnt
If this command returns silently, it usually means success.
1.4 Verify the NFS mount
Now verify that the folder is actually mounted on /mnt.
You can check with:
mount | grep nfs
Or list the contents of /mnt and see if the server file is there:
ls -l /mnt
You should see the file you created earlier on the server, like:
test-from-server.txt
That confirms the client is reading data from the NFS server correctly.
1.5 Test write access from the client
Now let’s make sure you can write to the shared folder from the client.
On the client, inside /mnt, create a test file:
sudo sh -c 'echo "Hello from NFS client" > /mnt/test-from-client.txt'
Then, back on the NFS server, check that the file appears in /share_nfs:
ls -l /share_nfs
You should see both server-created and client-created files there. That proves the NFS share is working in both directions.
If you hit permission errors here, it’s usually about ownership or export options in /etc/exports on the server. In that case, revisit your export line and make sure it allows the client to write.
Step 2 – Configure NFS Mount at Boot with fstab
Right now, if you reboot the client, the NFS mount disappears. For a real setup, you usually want the NFS share to mount automatically at boot.
We’ll use /etc/fstab on the client for that.
2.1 Create a dedicated mount directory
Instead of using /mnt forever, it’s cleaner to have a dedicated directory, e.g. /mnt/share_nfs.
On the client, create it:
sudo mkdir -p /mnt/share_nfs
Why this matters: a clear mount point makes scripts and backups easier later.
2.2 Edit /etc/fstab on the client
Now tell the client to mount the NFS share on boot.
Open /etc/fstab on the client:
sudo nano /etc/fstab
Scroll to the bottom and add a new line for the NFS mount. The original article provides a direct example line here. Keep the structure consistent with that, referencing:
- The NFS server IP:
192.168.100.1 - The export:
/share_nfs - The local mount point:
/mnt/share_nfs - The required NFS options used in the source
In simple form, the pattern looks like:
server:/remote/path /local/path nfs options 0 0
But for your setup, use the exact line given in the original article that matches 192.168.100.1:/share_nfs and /mnt/share_nfs.
Save and close the file.
2.3 Test fstab entry without reboot (safer)
Before you reboot and potentially get stuck because of a typo, test the new entry.
On the client, run:
sudo mount -a
If there’s a problem in /etc/fstab, you’ll see an error here. Fix any mistakes before rebooting.
If mount -a returns cleanly, check:
mount | grep share_nfs
ls -l /mnt/share_nfs
You should see the same files from the NFS server.
2.4 Reboot and verify auto-mount
Now reboot the client machine to make sure the NFS share comes up automatically:
sudo reboot
After it comes back up, check again on the client:
mount | grep nfs
ls -l /mnt/share_nfs
You should see the NFS line in mount output and the server-side files inside /mnt/share_nfs without having to run any manual mount command.
If it didn’t mount:
- Make sure the NFS server is up and NFS service is running.
- Double-check the
/etc/fstabline for typos. - Use
dmesgorjournalctlon the client to see boot-time mount errors.
Quick Troubleshooting Checklist
If something doesn’t work, here are the basic checks that match this setup.
From the client side:
-
Network reachability
ping 192.168.100.1– if this fails, fix network before touching NFS. -
Exports visible
showmount -e 192.168.100.1– if this shows nothing, recheck/etc/exportsand NFS service on the server. -
Manual mount before fstab
Trysudo mount 192.168.100.1:/share_nfs /mntbefore adding anything to/etc/fstab. If manual mount fails, fstab definitely won’t work. -
fstab syntax
Ifsudo mount -athrows errors, fix the last line you added. Even a missing space can break it.
From the server side:
-
Service running
Restart NFS after editing exports:
sudo systemctl restart nfs-kernel-server -
Export file mistakes
Check/etc/exportsfor the correct path (/share_nfs) and correct client/network. -
Check shared folder contents
ls -l /share_nfs– make sure files created from client really land here.
Once these basics are clean, NFS is usually pretty stable.
Wrap-Up
You now have a basic NFS setup:
- Debian 9 serving a shared folder via NFS.
- A Linux client that can mount the share manually.
- An automatic mount at boot using
/etc/fstab.
This is enough for simple LAN file sharing between Linux/Unix machines without extra overhead.
If you later add more clients or want more complex permissions, you’ll extend the /etc/exports configuration on the server and repeat the client-side mount steps for each machine.
Need more help? Check the latest CrushEdge posts.
No Comments