Last updated on July 7th, 2024 at 10:51 am
Just in case you need to know how...
This post may contain affiliate links. We may earn a commission if you purchase an item through our links. It costs you nothing and helps us to fund this blog. Please see our Affiliate Disclosure & Notification for details.
Summary: How to create an NFS share on Linux Mint that can be accessed from any system that supports NFS connections such as Windows, OSX, & VMware.
Windows File Sharing is pretty ubiquitous these days. It can be locked down for security pretty well using a combination of NTFS and share permissions. So what happens when you have an environment with mixed operating systems or systems that can’t read NTFS permissions? Create an NFS share.
NFS (Network File System) allows a system to share directories with other computers on the network much like a Windows file share, but without the need for Windows. By using NFS, users and programs can access files on remote systems almost as if they were local files. NFS is typically faster than Windows-based file shares. NFS is so fast over a gigabit Ethernet connection, it’s almost as if you’re using a locally connected drive.
A Use Case for NFS Shares using Linux Mint
I created NFS shares on Linux Mint so that I could mount them as datastores on my VMware hosts. As a small company, I don’t have the capital or need for a 6-figure enterprise storage solution. But VMware won’t use a Windows file share as a datastore. Windows files shares are too slow to run actual virtual machines from.
In my case, I had a couple of older PCs laying around that each had 500GB hard drives in them. I installed Linux Mint on the 2 computers and wanted to share out a directory on them to use as a VMware datastore.
Creating an NFS Share in Linux Mint – Installing the Packages
The first step is to install the necessary application packages on your Linux Mint computer. Open terminal and type the following command:
sudo apt-get install nfs-kernel-server nfs-common portmap
The 3 packages you’re installing here allow you to create NFS shares with the least amount of clunkiness. Select yes at all of the prompts and move on to the next step.
Creating an NFS Share in Linux Mint – Create the Directory
Because you have to refer to NFS shares in terms of absolute paths, it’s best not to create them way down in the directory tree. I put all of my NFS shares right in the /etc/ directory. You’ll have to open the /etc/ directory as root in order to create a folder here.
Once the folder is created, I like to modify the permissions so that the users group has read & write permissions to the directory.
Creating an NFS Share in Linux Mint – Modify the Export File
Search in your /etc/ directory for a file called “exports”. You’ll modify this file to make the directory available as an NFS share. You can only modify the export file must as the root user on the Linux Mint system. This is what the export file looks like on one of my systems:
# /etc/exports: the access control list for filesystems which may be exported
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/etc/CGS-MINT01-Datastore 192.168.1.1/24(rw,no_root_squash,sync)
Decoding the Exports File
Notice that the only line not commented out by the # is the last line in the file. The last line designates the directory CGS-MINT01-Datastore inside the /etc/ directory as an NFS share. The 192.168.1.1/24 tells the system that only computers in that network address range are allowed to connect. You could also limit this to a single IP address or use a * to allow all computers to connect. Inside the parenthesis, we’ve designated rw which provides read/write access to the directory. If you just wanted read only, you’d use ro instead. The code no_root_squash states that root on the client machine will have the same level of access to the files as root on the server.
Finally, the sync command tells the system to only consider a file write complete once it has been moved to stable storage. This will slow down your file transfer speed but it helps to ensure that the NFS share doesn’t become corrupted during an unplanned server reboot. I use this option for NFS shares that I’m going to be hosting actual virtual machine files on because losing an entire VM is highly inconvenient. If you wish to have more performance at the risk of corruption, you can use the async configuration instead.
For more details on other options in the export file, check out this article on NFS shares with Linux Mint & Ubuntu.
Restart the NFS Server Service
Type this command into terminal on your Linux Mint system:
sudo service nfs-kernel-server restart
You’re now ready to connect to your new NFS shares.
From VMware you’ll need to add a new datastore and then choose to mount an NFS datastore. From there you’ll choose a name for your datastore and then enter the server & absolute path to the datastore.
In Windows you’ll need to go to add/remove Windows features in order to install the NFS client. Once you do that, it’s the same as mapping a network drive.
NFS Shares: A Practical Alternative to Windows File Shares
NFS Shares may seem a bit mysterious if you’ve never dealt with them before. It’s quite simple though. You can perform all the steps in this article in just a few minutes. With NFS on Linux Mint, you can essentially turn any old computer into a file server without having to pay for an expensive operating system. Since Linux Mint is free, your only expense is the electricity to run all those boxes!
Sharif Jameel is a business owner, IT professional, runner, & musician. His professional certifications include CASP, Sec+, Net+, MCSA, & ITIL and others. He’s also the guitar player for the Baltimore-based cover bands, Liquifaction and Minority Report.
correct line for restarting NFS on linux mint 20 is:
service nfs-kernel-server restart
Thanks for the correction! I think when I wrote this, I was using Linux Mint 17 or 18. I’m not sure if the command was different then or if I just typo’d it when I wrote up the article, but thank you!