8

I have no problems mounting a network drive W: with the following command:

sudo mount -t drvfs W: /mnt/htdocs

In /proc/mounts the corresponding line then is:

W: /mnt/htdocs drvfs rw,relatime 0 0

But if I add this line to /etc/fstab and restart, I would expect the system to auto-mount the drives, which doesn't happen.

Any ideas?

8
+50

WSL does process fstab, but only as of build 17093. Assuming you're using an earlier version, you'll probably need to write a script to do the mount and invoke it manually.

1

Windows build 17093 is supposed to fix the fstab problem, but at the moment it is only an Insider Build, so not advised for stability.

You can effectively accomplish this by writing a .bash_login script in your home directory like this:

if [ ! -e full_file_name ]
then sudo mount --bind ...
fi

Just replace the mount command by whatever mount commands you want, and full_file_name with a file-name that will reliably exist if your mounts are in place.

The first Linux window might require you to type your Linux password, but later windows will not.

0

I suspect that WSL ignores /etc/fstab. You have access to other Windows files because WSL automatically mounts all open Windows partitions. Note that there is no /dev/sda when Ubuntu runs under WSL.

  • The wslconfig documentation says /etc/fstab is processed by default. – Bob Feb 15 '18 at 16:02
  • 2
    it also says "Available in Windows Insider Build 17093 and later" – sickelap May 5 '18 at 9:43
0

I ran into the same problem.

I am running Windows 10 Enterprise Version 1709, OS Build 16299.431

What I did is I added to the top of /etc/bash.bashrc the following line:

sudo mount -t drvfs '\\127.0.0.1\MyDrive' /mnt/MyDrive

I am not saying this is the best way to go about it, but I was sure tired of having to mount the drive every time I started WSL bash.

0

I ran into the same problem.

What I did to fix it was, go to the /etc/bash.bashrc and add the below script at the top:

sudo rm -r /mnt/d
sudo mkdir /mnt/d
sudo mount -t drvfs D: /mnt/d

Please note that D is my network drive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.