You can mount an NFS share from Windows Subsystem for Linux (WSL) in Windows 10 by installing the
nfs-common package within your Linux distribution and using the standard
mount command to attach the remote filesystem. This process allows WSL 2 instances to access network storage directly, enabling seamless file operations between your Linux environment and external NFS servers without requiring complex third-party tools or virtual machine configurations.
Prerequisites and Network Configuration
Before attempting to mount the share, ensure that your Windows host and the NFS server are on the same network segment and that firewall settings permit traffic on port 2049. WSL 2 runs in a lightweight utility VM with its own virtual network interface, which means it does not automatically inherit all host networking configurations. You must verify that the NFS server is reachable from the WSL environment by pinging the server’s IP address from inside your WSL terminal. If you encounter connectivity issues, check the Windows Defender Firewall inbound rules to ensure that the NFS service is allowed through the network boundary. It is also critical to confirm that the NFS server exports the specific directory you intend to mount and that the client IP address is whitelisted in the server’s export configuration.
Installing NFS Client Tools in WSL
WSL distributions do not include NFS client utilities by default, so you must install them manually. The exact command depends on the Linux distribution you are running within WSL. For Ubuntu, Debian, and their derivatives, open your WSL terminal and run the following command to update your package lists and install the necessary components:
sudo apt update
sudo apt install nfs-common
For Fedora, CentOS, or RHEL-based distributions, use the appropriate package manager:
sudo dnf install nfs-utils
After installation, verify that the
mount.nfs command is available by typing
mount.nfs --version. This confirms that the system has the binary required to negotiate the NFS protocol with the remote server. Without this package, any attempt to mount an NFS share will result in a "command not found" error or a failure to recognize the NFS filesystem type.
Creating a Mount Point
Linux requires a local directory to serve as the entry point for the remote filesystem. Create a dedicated directory within your WSL home folder or another appropriate location in the Linux file system. Using a specific path helps keep your mounts organized and makes it easier to manage permissions later. Execute the following commands to create the directory and set appropriate ownership:
mkdir -p ~/mnt/nfs_share
sudo chown $USER:$USER ~/mnt/nfs_share
This directory,
~/mnt/nfs_share, will act as the bridge between your local WSL environment and the remote NFS data. Ensure that no other processes are currently using this path before proceeding.
Mounting the NFS Share
With the client tools installed and the mount point ready, you can now connect to the NFS server. Use the
mount command with the
-t nfs flag to specify the filesystem type. Replace
<server_ip> with the actual IP address of your NFS server and
<remote_path> with the exported directory path on that server.
sudo mount -t nfs : ~/mnt/nfs_share
If the connection is successful, you can verify the mount by running
df -h or checking the contents of the mount directory with
ls ~/mnt/nfs_share. You should see the files and directories exported by the NFS server. If you encounter permission errors, ensure that the user ID (UID) and group ID (GID) mapping between your WSL user and the NFS server matches, or use the
uid and
gid options in the mount command to force specific ownership.
Making the Mount Persistent
By default, mounts created via the command line are lost when the WSL instance shuts down. To make the NFS share persist across reboots, you need to add an entry to the
/etc/fstab file. Open the fstab file with a text editor:
sudo nano /etc/fstab
Add the following line at the end of the file, replacing the placeholders with your specific details:
: /home//mnt/nfs_share nfs defaults,_netdev 0 0
The
_netdev option tells the system that this is a network device and to delay mounting until the network is available. After saving the file, you can test the configuration by unmounting the current share and running
sudo mount -a, which will attempt to mount all entries listed in fstab.
Troubleshooting Common Issues
If the mount fails, check the WSL logs located in
/var/log/syslog or use
dmesg to identify kernel-level errors. Common issues include incorrect NFS version negotiation; you can specify the version using the
-o vers=3 or
-o vers=4 flags if the default version fails. Additionally, ensure that the NFS server is not blocking the WSL2 virtual IP range. If you experience slow performance, consider adjusting the
rsize and
wsize parameters in the mount command to optimize data transfer sizes for your network latency. For more information on managing network connections in Windows, you might find our guide on closing listening ports useful, though this is distinct from NFS mounting.
Frequently Asked Questions
Can I mount an NFS share in WSL 1?
WSL 1 lacks full kernel support for mounting arbitrary filesystems like NFS directly. While you can access Windows drives, mounting remote NFS shares typically requires WSL 2 due to its Linux kernel capabilities. Attempting to use NFS commands in WSL 1 often results in compatibility errors or unsupported features.
Why is my NFS mount read-only?
A read-only mount usually indicates a permission mismatch between the WSL user and the NFS server’s export rules. Check the server’s configuration to ensure write access is granted for your client IP. You may also need to adjust the
ro vs
rw options in the mount command or the server’s exports file.
How do I unmount the NFS share?
To remove the mount, use the
umount command followed by the mount point path. Run
sudo umount ~/mnt/nfs_share to detach the filesystem. Ensure no active processes are using files within that directory before unmounting, as this will cause the operation to fail with a "device busy" error.
Does WSL 2 support NFSv4?
Yes, modern versions of WSL 2 fully support NFSv4. Most contemporary NFS servers default to NFSv4, and the
nfs-common package includes the necessary clients to handle this protocol. If you encounter issues, explicitly specifying the version in the mount command can help resolve negotiation problems.
What happens to the mount if the network disconnects?
If the network drops while the share is mounted, subsequent file operations may hang or return errors. The
_netdev option in fstab helps prevent automatic mounting during boot if the network is unavailable. During runtime, you may need to remount the share after the network connection is restored to regain access to the files.