I would like to mount drive D on /home directory in WSL while letting C drive to be mounted on /mnt or not mounting it at all. How can I do that?
Linux – How to mount windows 10 drive on WSL home directory
linuxmountwindows 10windows-subsystem-for-linux
Related Solutions
Good news, it is now possible to mount USB media (including formatted as FAT) and network shares with drvfs on Windows 10:
Mount removable media: (e.g. D:)
$ sudo mkdir /mnt/d
$ sudo mount -t drvfs D: /mnt/d
To safely unmount
$ sudo umount /mnt/d
You can also mount network shares without smbfs:
$ sudo mount -t drvfs '\\server\share' /mnt/share
You need at least Build 16176 so you might have to opt-in to the Windows Insider programm and then update Windows. Source: https://blogs.msdn.microsoft.com/wsl/2017/04/18/file-system-improvements-to-the-windows-subsystem-for-linux/
Where is the Docker daemon running? I'm guessing it's running on a server somewhere or if you're using Docker for Windows (with Windows containers/LCOW), it's running on the host outside WSL. The bind mount is likely looking for "/home/username" on the host instead of inside the WSL environment where the Docker client is running. Based on your comment about /c and /d working, it sounds like these are getting mapped back to C:\ and D:\ drives on the host which suggests you're using Docker for Windows
From inside WSL, it looks like drives are mounted inside WSL but the rootfs lives on a virtual file system which would explain why /c and /d are working
nick@nick-desktop:/mnt$ mount
rootfs on / type lxfs (rw,noatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,noatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,noatime)
none on /dev type tmpfs (rw,noatime,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,noatime,gid=5,mode=620)
none on /run type tmpfs (rw,nosuid,noexec,noatime,mode=755)
none on /run/lock type tmpfs (rw,nosuid,nodev,noexec,noatime)
none on /run/shm type tmpfs (rw,nosuid,nodev,noatime)
none on /run/user type tmpfs (rw,nosuid,nodev,noexec,noatime,mode=755)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noatime)
C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000)
W: on /mnt/w type drvfs (rw,noatime,uid=1000,gid=1000)
X: on /mnt/x type drvfs (rw,noatime,uid=1000,gid=1000)
Z: on /mnt/z type drvfs (rw,noatime,uid=1000,gid=1000)
Here is some documentation that talks about how the Linux rootfs in WSL works https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/
The location in Windows WSL rootfs lives inside of is listed in KCU:\Software\Microsoft\Windows\CurrentVersion\Lxss (see https://github.com/Microsoft/WSL/issues/2578)
Here is some additional information on Docker architecture explaining the difference between Docker daemon and client https://docs.docker.com/engine/docker-overview/
Best Answer
I figured it out. There is a setting to mount manually instead of automount.
To disable
[automount]
I should setenable
key inwsl.conf
tofalse
. Here is my/etc/wsl.conf
:Also, I should have added the following line to
fstab
.and it did work. Just do not forget to have
.bashrc
and.profile
in your D drive.