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.
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.
If the machine is Fedora-based, the command would be:
If the machine is Arch-based, the command is:
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.
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.
You can now start the NFS service. The same command can be used on Arch, Fedora, and Ubuntu systems. That command is:
The server should start and is now ready for connections.
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:
Next, open the fstab file with the command:
At the bottom of the file, add the following line:
Where USER is your Linux username.
Save and close the file. Verify the configuration with:
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.
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.
Comments