UNDER CONSTRUCTION!!!

Tech News

Keeping You Up To Date With The Latest Tech News & Virus Threats
Font size: +

How to set up a Linux NFS server on your home network (and why)

file sharing
Abscent84/Getty Images

I have various folders shared across my network. Some of those folders are for smaller files that need to be accessed from every machine on my LAN (Local Area Network), while others tend to be used for larger files (such as videos). However, for those smaller files (such as backup copies of galleys), I use Samba because it's flexible and easy to use. For the larger files, I often go with NFS.

Also: Need to transfer files between Linux machines? Here are 5 dependable solutions

NFS stands for Network File System and is a straightforward system for sharing folders across a network. Other than the flexibility, Samba is a bit easier to work with than NFS, which is why so many opt to go that route. But when you need to save larger files to a network share, NFS is a good route to go.

I want to show you how to set up an NFS share on your network, using Linux.

How to install NFS

What you'll need: The only things you'll need for this are a running instance of Linux (I'll demonstrate on the Ubuntu-based Pop!_OS), a user with sudo privileges, and a home network.

sudo apt-get install nfs-kernel-server -y

If the machine is Fedora-based, the command would be:

sudo dnf -install libnfsidmap sssd-nfs-idmap nfs-utils -y

If the machine is Arch-based, the command is:

sudo pacman -S nfs-utils
sudo apt-get install nfs-common -y

How to create an NFS share

sudo mkdir /share
sudo chmod -R 777 /share

How to define our new share with NFS

The next step is to define the new share. For that, you'll need to know the IP address of the machine that will access the share. With that information in hand, let's define the share.

sudo nano /etc/exports
/share ADDRESS(rw)

Where ADDRESS is the IP address of the client machine that will access the NFS share. The rw means the client will have read and write access to the share.

How to open the firewall

sudo firewall-cmd --permanent --zone=public --add-service=nfs sudo firewall-cmd --reload
sudo ufw allow from 192.168.1.0/24 to any port nfs

Start the service

You can now start the NFS service. The same command can be used on Arch, Fedora, and Ubuntu systems. That command is:

sudo systemctl --enable now nfs-server

The server should start and is now ready for connections.

How to mount the share

Unlike Samba, the share isn't automatically visible to your network. Instead, you need to mount it from your other Linux machines. Here's how to do that. 

Say the IP address of your NFS server is 192.168.1.176 and the share is /share. To mount that on a client machine, you'll first need to create a folder for which to mount the share. On your client machine, issue the command:

nano mkdir ~/nfs_mount

Next, open the fstab file with the command:

sudo nano /etc/fstab

At the bottom of the file, add the following line:

192.168.1.176:/share /home/USER/nfs_mount nfs rw 0 0

Where USER is your Linux username.

Save and close the file. Verify the configuration with:

sudo mount -a

You should see no errors in the output.

Also: 5 Linux file and folder management commands you need to know

At this point, the NFS share is now accessible on your Linux machine from your ~/nfs_mount directory. Any files already in the share will be available and any file you add to ~/nfs_mount (on the client) will appear in the /share directory on the server. Because we added the mount command to /etc/fstab, the share will automatically mount, even after a reboot.

×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Diablo 4 has made $1 billion and counting for Bliz...
An Asteroid Is Going to Orbit Earth Like a Mini Mo...
 

Comments

No comments made yet. Be the first to submit a comment
Already Registered? Login Here
Thursday, 14 November 2024

Captcha Image

I Got A Virus and I Don't Know What To Do!

I Need Help!