How to create a persistent mounting point in Ubuntu app on Windows-10
I'm assuming you're using WSL (Windows Subsystem for Linux) Ubuntu. Then to preserve your mounting points between sessions you need to edit fstab
file which is located in /etc
directory
In your case you should add to your fstab something similar to:
H: /mnt/h drvfs defaults 0 0
instead of H:
(your disk name) you can also use your network location \\server\share\
Please note, you should be using at least 17093 build of WSL in order to fstab
to be processed.
Note: Make sure you actually create an empty dir for the mount-point first, e.g. sudo mkdir /mnt/h
.
Related videos on Youtube
Dominique
Updated on September 18, 2022Comments
-
Dominique over 1 year
On my Windows-10 machine, I have a Ubuntu app, which I use for handling files on my local PC. In order to do this, I have two mounting points (one for every harddisk, as you can see):
Ubuntu Prompt>mount ... C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000) E: on /mnt/e type drvfs (rw,noatime,uid=1000,gid=1000)
On my Windows-10 PC, I also have a network drive, as you can see in following
WMIC
result:Windows Prompt>>wmic logicaldisk get Caption, Description Caption Description C: Local Fixed Disk ... E: Local Fixed Disk H: Network Connection ...
I am capable of mounting the H:-drive as a mounting point (which makes it easily accessible from my Ubuntu app), as you can see:
Ubuntu Prompt> sudo mount H: /mnt/h -t drvfs Ubuntu Prompt> mount ... C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000) E: on /mnt/e type drvfs (rw,noatime,uid=1000,gid=1000) H: on /mnt/h type drvfs (rw,relatime)
However, when I close the Ubuntu app and re-open it, the H:-drive related mounting point has disappeared:
Ubuntu Prompt> mount ... C: on /mnt/c type drvfs (rw,noatime,uid=1000,gid=1000) E: on /mnt/e type drvfs (rw,noatime,uid=1000,gid=1000) // No H:-drive mounting point anymore!
Is there a way I can make this mounting point persistent?
Thanks in advanceEdit after first reply
The Ubuntu app I'm using has following specifications (Windows start button, Apps and Features (System settings)):
Publisher : Canonical Group Limited Version : 1804.2018.817.0 App : 0 bytes Data : 0 bytes Total usage : 0 bytes
As far as
fstab
is concerned, this is the result of thefind / -name "fstab" 2>/dev/null
command:/etc/fstab /mnt/c/cygwin/etc/fstab /mnt/c/cygwin64/etc/fstab /mnt/c/MinGW/msys/1.0/etc/fstab /mnt/c/Program Files/Git/etc/fstab /mnt/c/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/Git/etc/fstab /mnt/c/Users/DominiqueDS/AppData/Local/GitHubDesktop/app-1.1.1/resources/app/git/etc/fstab /usr/share/doc/mount/examples/fstab /usr/share/doc/util-linux/examples/fstab
I believe the one I need is the first one, but this one currently has following content:
Ubuntu prompt> cat fstab LABEL=cloudimg-rootfs / ext4 defaults 0 0
This format is so different of the format within the first reply that I'm reluctant to use it (imagine I can't start up my Ubuntu app anymore, due to corrupted mounting points).
Can you confirm me that this is the right
fstab
indeed and that the mentioned format is correct? -
Dominique about 5 yearsThanks for your quick reply, but I'm having some doubts, as mentioned in the edit of my question. Can you confirm that I'm working correctly?
-
Ludwik about 5 years@Dominique You should indeed use
/etc/fstab
file, and I believe the lineH: /mnt/h drvfs ro defaults 0 0
is correct. In case something goes wrong (but it shouldn't) you can edit fstab file from windows to revert the changes:%LOCALAPPDATA%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs
-
Dominique about 5 yearsI've done the changes, but it seems not to be working: after having restarted the app, the mounting point did not get recreated. By the way, when running
uname -a
I get following result, I believe this means I'm working with build 17134? (Linux DOMINIQUEDS 4.4.0-17134-Microsoft #523-Microsoft Mon Dec 31 17:49:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
) -
Ludwik about 5 years@Dominique - there was a mistake in the line I suggested, but I edited my answer, and it should be ok now. Can you please try it? You can mount all entries from fstab with
sudo mount -a
and then check if they're mounted withmount
-
Jérôme MEVEL over 4 yearsI confirm it's working, this is the answer I was looking for. (I was on the wrong path trying to modify
/etc/wsl.conf
) -
Jérôme MEVEL over 4 yearsI'd like to add, of course one must create the
/mnt/h
directory otherwise it silently fails