Mount a drive into WSL distro owned by a restricted user
Is your feature request related to a problem? Please describe. I use Windows and WSL as a restricted user. However, mounting drives is only possible for Windows elevated admin account. I have access to admin account. However, it does not have access to restricted user's WSL distrubutions.
Describe the solution you'd like A way to mount a drive into restricted user WSL distributions, given user has access to elevated admin account.
Additional context
Restricted user:
C:\Users\User>wsl.exe -l -v
NAME STATE VERSION
* Ubuntu Running 2
Alpine Stopped 2
Ubuntu-20.04 Stopped 2
C:\Users\User>wsl.exe --mount \\.\PHYSICALDRIVE1 --partition 1
Administrator access is needed to mount a disk.
Error code: Wsl/Service/AttachDisk/WSL_E_ELEVATION_NEEDED_TO_MOUNT_DISK
If Admin has no installed distributions:
C:\Windows\system32>wsl.exe --mount \\.\PHYSICALDRIVE1 --partition 1
This operation is only supported by WSL2.
Error code: Wsl/Service/AttachDisk/WSL_E_WSL2_NEEDED
C:\Windows\system32>C:\Users\User\AppData\Local\Microsoft\WindowsApps\wsl.exe -l -v
Windows Subsystem for Linux has no installed distributions.
...
If Admin has installed distributions, mounting succeeds for Admin but disk is only visible in Admin's distributions.
Versions
>wsl --version
WSL version: 1.0.3.0
Kernel version: 5.15.79.1
WSLg version: 1.0.47
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.2364
Related/Duplicates #6147, #2979, #6414
I can confirm this issue on my installation of WSL2 and Ubuntu.
WSL version: 1.0.3.0 Kernel version: 5.15.79.1 WSLg version: 1.0.47 MSRDC version: 1.2.3575 Direct3D version: 1.606.4 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.19045.2364
Lsblk shows drive only in WSL of elevated user. Mounting is only possible if elevated user has WSL installed.
I can confirm same problem:
As Admin
PS D:\WSL\shared> wsl --version WSL version: 1.2.5.0 Kernel version: 5.15.90.1 WSLg version: 1.0.51 MSRDC version: 1.2.3770 Direct3D version: 1.608.2-61064218 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.19045.2846 PS D:\WSL\shared> wsl --mount .\PhysicalDrive2 --bare
Error message: (I dont understand) This operation is only supported by WSL2. Error code: Wsl/Service/AttachDisk/WSL_E_WSL2_NEEDED
as user:
PS D:\WSL\shared> wsl -l -v NAME STATE VERSION
- Ubuntu-18.04 Stopped 2 CentOS Running 2 EL8 Stopped 2 PS D:\WSL\shared> wsl --mount \.\PhysicalDrive2 --bare Administrator access is needed to mount a disk. Error code: Wsl/Service/AttachDisk/WSL_E_ELEVATION_NEEDED_TO_MOUNT_DISK PS D:\WSL\shared>
Same here:
> wsl -v
WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19044.2965
> wsl --mount \\.\PHYSICALDRIVE1
Administrator access is needed to mount a disk.
Error code: Wsl/Service/AttachDisk/WSL_E_ELEVATION_NEEDED_TO_MOUNT_DISK
Same here.
wsl -v WSL-version: 1.2.5.0 Kernel version: 5.15.90.1 WSLg version: 1.0.51 MSRDC version: 1.2.3770 Direct3D version: 1.608.2-61064218 DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Windows version: 10.0.22000.1574
wsl --mount \.\PHYSICALDRIVE1 Administrator access is needed to mount a disk. Error code: Wsl/Service/AttachDisk/WSL_E_ELEVATION_NEEDED_TO_MOUNT_DISK
wsl 2 the same
PS C:\Users\user> wsl --mount \\.\PHYSICALDRIVE2
Administrator access is needed to mount a disk.
Error code: Wsl/Service/AttachDisk/WSL_E_ELEVATION_NEEDED_TO_MOUNT_DISK
PS C:\Users\user> wsl -v
WSL-version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.3693
wsl 2.2.4.0 the same :(
PS C:\Users\Eduardo> wsl --mount \\.\PHYSICALDRIVE1 --bare
Administrator access is needed to mount a disk.
Error code: Wsl/Service/AttachDisk/WSL_E_ELEVATION_NEEDED_TO_MOUNT_DISK
PS C:\Users\Eduardo> wsl -v
WSL version: 2.2.4.0
Kernel version: 5.15.153.1-2
WSLg version: 1.0.61
MSRDC version: 1.2.5326
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26091.1-240325-1447.ge-release
Windows version: 10.0.19045.4529
No solution to this problem?
Same problem here.
+1
Yet another user here! Same problem.
There would be some process lock this disk, then you can not wsl mount it. Try to remove the disk or kill the process which might using the disk, especially the terminal and then re-mount it via wsl, and then finally use admin account for this action.
I think I found a workaround for this issue. First I uninstalled Windows and then I installed a native Linux distro on my laptop. I can't really explain it, but those simple steps appear to have fixed the issue.