Skip to content
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 · 15 comments
Closed

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

raymod2 opened this issue Apr 14, 2017 · 15 comments

Comments

@raymod2
Copy link

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
Copy link

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.

@Aerocatia
Copy link

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

@raymod2
Copy link
Author

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
Copy link
Author

raymod2 commented Apr 15, 2017

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

@aseering
Copy link
Contributor

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

@sgtoj
Copy link

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
Copy link
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

@sgtoj
Copy link

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
Copy link

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
Copy link
Collaborator

Ref #2636

agross added a commit to agross/dotfiles that referenced this issue Nov 18, 2017
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
Copy link

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
Copy link

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
Copy link
Member

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

@lemmy04
Copy link

lemmy04 commented Sep 21, 2020

...where is that wsl.conf file supposed to be...?

@jonaskuske
Copy link

...where is that wsl.conf file supposed to be...?

/etc/wsl.conf :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests