New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing mount point from /mnt/c to /c #1918

Closed
raymod2 opened this Issue Apr 14, 2017 · 13 comments

Comments

Projects
None yet
9 participants
@raymod2

raymod2 commented Apr 14, 2017

Years of using MSYS and MSYS2 has ingrained the habit of referring to the C: drive as "/c" but Bash on Windows uses "/mnt/c". A good solution is using a bind mount:

mkdir -p /c
sudo mount -o bind /mnt/c /c

However, this requires root and needs to be run every time you open a bash window. I tried using /etc/fstab for a persistent mount but I couldn't get it to work:

sudo sh -c "echo '/mnt/c /c none bind' >> /etc/fstab

@jack775544

This comment has been minimized.

jack775544 commented Apr 14, 2017

As a workaround you could possibly edit your sudoers file to allow any user to use access mount without root privileges and then add that command to your profile script.

@Vaporeon

This comment has been minimized.

Vaporeon commented Apr 15, 2017

Why not just ln -s /mnt/c /c?
I personally think /mnt/x is a more sane default.

@raymod2

This comment has been minimized.

raymod2 commented Apr 15, 2017

Yeah a soft link works, too. One minor gripe with a soft link is that "ls /c" doesn't work. You need "ls /c/".

@raymod2

This comment has been minimized.

raymod2 commented Apr 15, 2017

BTW, this ticket is to look into why /etc/fstab doesn't work.

@aseering

This comment has been minimized.

Contributor

aseering commented Apr 15, 2017

I imagine this is because WSL doesn't perform most normal Linux systemwide initialization. See #511 , for example.

@sgtoj

This comment has been minimized.

sgtoj commented Nov 17, 2017

@raymod2 Here is the solution.

# created as su to match /mnt/c
sudo mkdir -p /c 
# update /etc/fstab; requires su
sudo sh -c "echo '/mnt/c /c none bind' >> /etc/fstab"
# reload fstab; requires su
sudo mount -a

Ticket probably can be closed now.

@therealkenc

This comment has been minimized.

Collaborator

therealkenc commented Nov 17, 2017

It's the sudo mount -a that people don't want to run, per what Adam alludes right above. fstab is not respected on WSL instantiation.

It is tempting to dupe these all into #511 ("make systemd work") but now there is precedent in #2530 for adding systemd features to WSL init. I hope that isn't the route this goes, but we'll have to let it play out.

Ref #1854

@therealkenc therealkenc added the init label Nov 17, 2017

@sgtoj

This comment has been minimized.

sgtoj commented Nov 17, 2017

@therealkenc You are correct. I should have posted my answered after testing closing and relaunching a session. Once I noticed I was wrong, I started putting something together to as a work around to share with my team and others.

@sgtoj

This comment has been minimized.

sgtoj commented Nov 17, 2017

My original solution is the proper linux solution. However, the solution currently does not work for Ubuntu for Windows because mounts are not auto loaded. See @therealkenc comments for more information.

In the meantime, I have documented and posted a short step-by-step guide to implement a workaround.

@therealkenc

This comment has been minimized.

Collaborator

therealkenc commented Nov 18, 2017

Ref #2636

agross added a commit to agross/dotfiles that referenced this issue Nov 18, 2017

WSL: support additional mounts
There are some preparations required:

* the user must be able to sudo mount --all without asking for su password
  add 'youruser ALL=NOPASSWD: /bin/mount, /bin/umount' to /etc/sudoers
* mount points need to be added to /etc/fstab, e.g.
  /mnt/c /c none bind
* mount points need to be created before mounting (e.g. sudo mkdir /c)
* more info: Microsoft/WSL#1918 (comment)
@d1egoaz

This comment has been minimized.

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:~$

OS Build: 17107.1000

@Nossiac

This comment has been minimized.

Nossiac commented Mar 11, 2018

@d1egoaz How to upgrade the latest OS build? The update center gave me " Version 1709, OS build 16299", seems not the one your had mentioned.

@benhillis benhillis removed the init label May 24, 2018

@benhillis

This comment has been minimized.

Member

benhillis commented May 24, 2018

/etc/wsl.conf allows you do do this in 1803.

@benhillis benhillis closed this May 24, 2018

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