Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mount a substed drive in windows Ubuntu subsystem

My development environment on Windows includes substed folders, i.e. the folder c:\MyBuild may be substed to a drive letter, say t:

In a Ubuntu subsystem terminal, I can bind the folder to a mount, as this

sudo mount --bind  /mnt/c/MyBuild /mnt/t

This works fine in the current shell, but its not persistent, and if a bash script is invoked externally, this mount is not present, and so the script may fail saying, folder/mnt/t/someFolder don't exist..

I did add the following to /etc/fstab, but its not working as expected

 /mnt/t /mnt/c/MyBuild none defaults,bind 0 0

How can I make this mount persistent in Windows Ubuntu subsystem?

like image 924
Totte Karlsson Avatar asked Mar 02 '18 22:03

Totte Karlsson


1 Answers

This issue could be a result of something called the Fast Boot for Windows. This setting is on by default on Windows 10. And on shutdown or reboot Windows simply reloads the C:\hiberfile.sys image and then locks its drive partitions for security. (Making changes to your NTFS partition while it is hibernated is risky. Because of this the WSL tool that mounts the partition will not mount it in Read/Write mode, if it sees the hibernation flag.)

I had the same issue, the drive mounted fine sometimes but at other times it refused to mount and that was very confusing and irritating.

To fix this, goto Control Panel > Hardware and Sounds > Power Options > Find a setting for "Turn on fast Startup" and uncheck the option. Restart your computer and you should have access to the disk.

like image 86
Nitin Nain Avatar answered Oct 10 '22 21:10

Nitin Nain