MountVHD and WSL

Code:
     _x64: 1
   _admin: 1
_elevated: 1

TCC  27.00.18 x64   Windows 10 [Version 10.0.19042.746]

I have used MountVHD to mount a .vhd as drive G:

When I switch to WSL (Version 1), I cannot access the G: drive;
Code:
g:\users\jlc\downloads\technotes>wsl
jlc@DESKTOP-H2JFFTF:~$ dir
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos  nano.save  twin
jlc@DESKTOP-H2JFFTF:~$ cd /mnt
jlc@DESKTOP-H2JFFTF:/mnt$ dir
c  d  e  f  g  h  r
jlc@DESKTOP-H2JFFTF:/mnt$ cd g
jlc@DESKTOP-H2JFFTF:/mnt/g$ dir
jlc@DESKTOP-H2JFFTF:/mnt/g$

Note well that I have no problem with the G: drive from Windows 10.

Can anyone else duplicate this?

Is this WAD?

Joe
 
May 20, 2008
11,046
90
Syracuse, NY, USA
1611339703124.png
 
May 20, 2008
11,046
90
Syracuse, NY, USA
I have only WSL2. That was in the same elevated TCC that I used to mount the VHD. It's also OK in an unelevated instance.

1611340584142.png


However, the vhd is apparently unmounted when the TCC which mounted it exits. In fact, if you're watching in DiskMgmt.msc, you can see it disappear.
 
I have only WSL2. That was in the same elevated TCC that I used to mount the VHD. It's also OK in an unelevated instance.

View attachment 3266

However, the vhd is apparently unmounted when the TCC which mounted it exits. In fact, if you're watching in DiskMgmt.msc, you can see it disappear.
That's what I like about the MountVHD command, when I exit the TCC session, the drive is automatically unmounted, and not usable anywhere else in Windows 10 until the .vhd is mounted again.

Hoping that @rconn can provide feedback on why I can't see the .vhd drive contents from WSL1.

Joe
 
May 20, 2008
11,046
90
Syracuse, NY, USA
That's in contrast to using DISKPART.EXE (which requires elevation and gives a UAC prompt). After it exits (and it's console closes) the vhd is still accessible (in WSL too). To use it ...

diskpart ... (wait)
DISKPART> select vdisk file="d:\work\test.vhd"
DISKPART> attach vdisk
DISKPART> exit

or

diskpart ... (wait)
DISKPART> select vdisk file="d:\work\test.vhd"
DISKPART> detach vdisk
DISKPART> exit
 
That's in contrast to using DISKPART.EXE (which requires elevation and gives a UAC prompt). After it exits (and it's console closes) the vhd is still accessible (in WSL too). To use it ...
...and now @rconn will probably fix MountVHD to work that way also.

Guess I will have to start using UnMountVHD at that time.

Unless, of course, he adds a switch to MountVHD so that it can still work like it does now.

Maybe a switch for /Global or /Local.

Joe