How can I mount an NFS share from WSL2 on Windows 10?

sudo mount -t nfs 192.168.1.101:/mnt/tank /mnt/tank

fails with

mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.

I'm running Ubuntu 20.04 LTS on windows-subsystem-for-linux.


Solution 1:

That error indicates that you're missing startup services, since WSL doesn't run systemd.

sudo /etc/init.d/rpcbind start
sudo /etc/init.d/nfs-common start

WSL2 changes ip addresses on each boot via the managed Hyper-V virtual switch, so you may need to ensure that the entire subnet is allowed on your server: 172.16.0.0/12

Edit: As an alternative, try this: https://github.com/arkane-systems/genie

It sets up a "bottle" to run systemd as pid=1 and can start the systemd services needed for nfs mounts.