Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ubuntu for Windows: Mounting C: Drive to WSL's Root
# allow `mount` cmd without password
echo "$USER ALL=NOPASSWD: /bin/mount" | (sudo su -c 'EDITOR="tee -a" visudo')
# add the mount directive to `fstab`
sudo mkdir -p /c
sudo sh -c "echo '/mnt/c /c none bind' >> /etc/fstab"
# update to `.bashrc` to auto mount at login
echo "sudo mount -a" >> ~/.bashrc
# now reload it
source ~/.bashrc
@sgtoj

This comment has been minimized.

Show comment
Hide comment
@sgtoj

sgtoj Nov 18, 2017

It is possible to mount C: drive to the /c along with the default of /mnt/c. Why? In addition to being more familiar for those who used Windows Git Bash, it allows for relative volume mounting when using docker-compose. However, it is not just as easy as adding it to the fstab and reloading the mounts. Although it does works, the mounts will have to be manually reload for next session.

Owner

sgtoj commented Nov 18, 2017

It is possible to mount C: drive to the /c along with the default of /mnt/c. Why? In addition to being more familiar for those who used Windows Git Bash, it allows for relative volume mounting when using docker-compose. However, it is not just as easy as adding it to the fstab and reloading the mounts. Although it does works, the mounts will have to be manually reload for next session.

@steffen-wirth

This comment has been minimized.

Show comment
Hide comment
@steffen-wirth

steffen-wirth Dec 16, 2017

@sgtoj thanks for sharing

@sgtoj thanks for sharing

@esteldunedain

This comment has been minimized.

Show comment
Hide comment
@esteldunedain

esteldunedain Jan 15, 2018

Thanks @sgtoj, works perfectly.

Thanks @sgtoj, works perfectly.

@d1egoaz

This comment has been minimized.

Show comment
Hide comment
@d1egoaz

d1egoaz Feb 24, 2018

FYI this is now possible to do it with wsl.conf https://docs.microsoft.com/en-us/windows/wsl/wsl-config
root = /

diego@diego-thinkpad:~$ cat /etc/wsl.conf
# Enable extra metadata options by default
[automount]
enabled = true
root = /
options = "metadata,umask=22,fmask=11"
mountFsTab = false

# Enable DNS – even though these are turned on by default, we’ll specify here just to be explicit.
[network]
generateHosts = true
generateResolvConf = true

diego@diego-thinkpad:~$ mount -l | grep drvfs
C: on /c type drvfs (rw,noatime,uid=1000,gid=1000,umask=22,fmask=11,metadata)
diego@diego-thinkpad:~$

d1egoaz commented Feb 24, 2018

FYI this is now possible to do it with wsl.conf https://docs.microsoft.com/en-us/windows/wsl/wsl-config
root = /

diego@diego-thinkpad:~$ cat /etc/wsl.conf
# Enable extra metadata options by default
[automount]
enabled = true
root = /
options = "metadata,umask=22,fmask=11"
mountFsTab = false

# Enable DNS – even though these are turned on by default, we’ll specify here just to be explicit.
[network]
generateHosts = true
generateResolvConf = true

diego@diego-thinkpad:~$ mount -l | grep drvfs
C: on /c type drvfs (rw,noatime,uid=1000,gid=1000,umask=22,fmask=11,metadata)
diego@diego-thinkpad:~$
@ndotb

This comment has been minimized.

Show comment
Hide comment
@ndotb

ndotb May 4, 2018

This is awesome. Thank you.

ndotb commented May 4, 2018

This is awesome. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment