In setting up a NAS share to a new WSL2 installation (Ubuntu 20.04), I've found a couple ways to mount the drive that work perfectly fine:

  1. in /etc/fstab:

    //nas-hostname/public /mnt/nas cifs user=$username,pass=$pass 0 0

    Then sudo mount -a

  2. sudo mount -t drvfs '//nas-hostname/public' /mnt/testnas

I've tried wsl.conf, but it does not seem to work for network drives, only local Windows drives.

I would like to mount this drive automatically when the WSL2 comes online, reboots, or anything else. I am running a couple services which require the network drives to be present when the containers start. I am trying to identify the best way possible to do this. I am not a WSL (or Linux at all) expert, so I'm unclear whether the best route (i.e. most WSL idiomatic way) is to enable cron service on the machine, to set something in task scheduler, or something else.

I do have the drive mounted to the Windows host as Z:\ as well, but I would not prefer to map it to the Linux subsystem this way, as I'd like to be easy to shift to another host wholesale.


3 Answers 3


So the way I ended up getting this working is not great but it gets the job done. Hopefully somebody will submit a better answer later!

  1. Setup my user to allow sudo access without password to the mount command (using visudo).
  2. Add as the final line in my .bashrc file mount -a which mounts based on what I setup in /etc/fstab above.

Now all drives properly mount when the computer boots up. No further issues.


You solved it... but zfs in your wsl or nas and zfs share a viable option I used (and a windows task). So ignore the unreferenced brief below [better answered https://www.reddit.com/r/zfs/comments/lcdxs5/zfs_in_wsl2_raw_disk_access/ and smb/cifs shares i'll find..

ssh [email protected] (or... wsl --mount //?/PHYSICALDRIVEX/ --bare && wsl -d mydistro-with-zfs-wsl2-kernel..)
sudo apt install zfs-dkms zfsutils-linux samba nfs-kernel-server
sudo zpool create -o foo -O bar stank && sudo zfs create stank/DATA/usershares
Per arch-wiki or ubuntu or voidlinux wiki recommendations...
sudo rsync -haHAX /myoldfs[/] /stank/DATA/usershares
sudo zfs share
Find it in networks in file explorer

Add _netdev option to the fstab entry, it tells mount to wait for the network before attempting to mount them.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .