Do you want to share files between computers with various operating systems like Windows and Linux? One way to share and access files between Windows and non-Windows machines is by deploying a Network File System (NFS) server.
In this tutorial, you will learn step-by-step how to install and configure NFS Windows Server and access NFS shares from Windows or Linux.
Prerequisites
This tutorial will be a hands-on demonstration. If you’d like to follow along, be sure you have the following:
- An Active Directory (AD) domain. The examples in this tutorial will be working with a domain called HomeLab.Local.
- A server running on Windows Server 2012 or later operating systems where you’ll configure the NFS server role. This tutorial uses a domain-joined Windows Server 2019, and the server hostname is JumpBox.
- A domain-joined client PC that you’ll use to access the NFS shares. This tutorial will cover the procedures using Windows 10 version 2004 and Ubuntu 20.04 computers.
Performing NFS Server Windows Installation
After you’ve squared away the requirements, you should now have a Windows Server with no server roles. But you can quickly remedy that by following the steps below to install the NFS Windows Server.
1. Before anything, login to the server where you’ll set up NFS.
2. Next, open the Server Manager by clicking on Start —> Server Manager.
3. On the Server Manager window, click Add roles and features under the Dashboard tab.
4. On the Before you begin page, click Next.
5. On the Installation Type step, click Role-based or feature-based installation, and click Next.
6. On the Select destination server page, click the Select a server from the server pool option. Under the Server Pool list, click the server name for the NFS deployment and click Next.
7. On the Select server roles page, scroll down and expand the File and storage services node, and below that, expand the File and iSCSI Services, too. Now, check the box for Server for NFS.
On the pop-up window, the Wizard asks you to confirm installing the required features along with the NFS server role. To confirm, click Add features and click Next.
8. Since you’ve already confirmed adding the required features in the previous step, don’t select anything on the Select features page and click Next.
9. Lastly, on the Confirm installation selections page, click Install to install the NFS server role.
10. After the installation is complete, click Close to close the Wizard.
Note: You can have more than one NFS Servers in your network.
Configuring an NFS Server Windows Share
You’ve just completed a new NFS Server Windows installation. Good job! Now that the NFS server runs in the background, you still have steps to make your server useful. An NFS server’s purpose is to share files, so let’s go ahead and configure your first NFS share.
1. On the left side of the Server Manager, expand the File and storage services option and click on Shares.
2. Next, near the top-right of the window, click on the Tasks drop-down —> New Share.
3. On the Select Profile step, there are two options for NFS Share:
- NFS Share – Quick – Creates an NFS share with basic settings and is suitable for sharing files with Unix-based computers. You can configure more settings later on.
- NFS Share – Advanced – This NFS share profile requires that the server also has the File Server Resource Manager role. This option allows setting folder owners, data classification, access policies, and quotas.
For this tutorial, select NFS Share – Quick and click Next.
4. Select the Type a custom path option on the Share Location step to share a custom location instead of sharing an entire volume.
Next, type the full path of the folder you want to share. In this example, the custom location to share is C:\Data.
Note: The custom location path you enter must already exist. If the location does not exist, the Wizard will ask if to automatically create the local path, as you can see below.
Finally, click Next.
5. On the Share Name page, the Share name by default is the share location’s folder name. For this step, accept the default share name and click Next.
You may change the share name to anything you deem best represents the NFS share. The Wizard automatically generates the Remote path to share value.
6. On the Authentication step, select which authentication methods you want to assign the NFS share. In this tutorial, select all the Kerberos options to allow clients to use the Kerberos authentication methods that the server supports.
Next, since this tutorial includes Linux clients, check the No server authentication (AUTH_SYS) box —> Enable unmapped user access —> Allow unmapped user access by UID/GID. Enabling this option allows clients without Kerberos capabilities to access the NFS share.
7. On the Share Permissions page, configure the permissions to the location that you are sharing. To begin, click Add. Next, choose which NFS clients can access the share.
8. On the Add Permission window, select All Machines to apply the permission to any NFS client that wants to access the share. Next, on the Share permissions drop-down, click Read / Write to allow read and write access. Finally, click Add.
9. Back on the Share Permissions page, click Next.
10. On the Permission page, click Next to accept the default / existing entries.
In future deployments, to restrict access to specific users or groups and what permissions they have, click Customize to add the specific users or groups.
11. On the Confirmation step, click Create.
12. After the Wizard has created the NFS share, click Close on the Results page to close the Wizard.
Note: You can create multiple NFS shares on one NFS server by following the same process.
Mounting the NFS Share on Windows Using the NET USE
Command
Without further configuration or installation, you can mount an NFS share to a location on your Windows computer by running the built-in net use
command. To do so, proceed as follows.
On your Windows client, open the command prompt and run the below command. This command will mount the NFS share to your computer and map it to the drive K.
Note: Do not run the net use command from an elevated command prompt. If you do, the drive letter will not appear in the File Explorer.s
Note that specifying the NFS server’s IP address instead of the name is also acceptable.
net use K: \\Jumpbox\Data /user:homelab\user01 <password>
You can now access the K: drive from the Windows Explorer.
Mounting the NFS Share Using the Client for NFS Windows Feature
Before you can mount an NFS share to your client computer, first, you need to install an optional Windows feature called Client for NFS. Only after installing this feature will the additional command to mount an NFS share will become available.
1. To install the Client for NFS feature, open PowerShell as admin and run the Enable-WindowsOptionalFeature
command below. The -All
parameter enables all features that the Client for NFS features requires.
Enable-WindowsOptionalFeature -FeatureName ClientForNFS-Infrastructure -Online -All
Now that you’ve installed the required NFS for Client feature, the mount.exe
command is now available, which you’ll use to mount the NFS share on your computer.
2. Open a command prompt window and run the command below. This command mounts the NFS share to your computer under the drive letter H.
mount.exe -u:homelab\user01 -p:<password> jumpbox:/data H:
3. Now, open the File Explorer to view and access the files inside the NFS share.
Connecting to an NFS Share from Linux
This section contains instructions running on an Ubuntu PC. If you are using a different Linux distro, some of the commands might be different. In which case, refer to your distro’s documentation.
So far, you’ve seen NFS in action by connecting to an NFS share from Windows. This time, take NFS for another spin using an Ubuntu PC. Proceed with the following instructions.
1. Open a terminal and run the below command to update the package lists on your PC. The sudo
command will ask for your password. Type in your password and press Enter.
sudo apt update -y
2. Next, run the below command to install the required packages to enable your PC as an NFS client. Wait for the installation to complete.
sudo apt install nfs-common -y
3. Next, create a folder where you’ll mount the NFS share. Run the below commands to do so.
# Create a folder under the current working directory
mkdir NfsMount
# Mount the NFS Share
# * "jumpbox:/Data" is the NFS share path
# * "NfsMount/" is the local folder you created where to mount the NFS share
sudo mount -t nfs jumpbox:/Data NfsMount/
If there are no errors, like the screenshot you see below, then you’ve successfully mounted the NFS share to your local directory.
4. Now, test your access to the NFS share by listing its contents.
ls NfsMount/
Alternatively, run the command below instead if you want to open the NFS share location using your default file browser.
xdg-open NfsMount/
5. Optionally, to allow non-admin users access to the NFS share, run the command below in the terminal. This command enables the read, write, and execute permissions to the NfsMount folder recursively for all users.
sudo chmod -R a+rwx NfsMount/
Conclusion
Deploying an NFS Server on Windows to share files between computers with different operating systems is a quick and convenient solution. And this tutorial gave you the fundamental knowledge on how to install, configure, and access NFS server Windows shares.
What you learned here are only the basics to get you started with NFS shares. Perhaps if you want to go further, try to configure unmapped UNIX user access or configure NFS account mapping using AD DS. Thanks for reading!