WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Mount a drive into WSL distro owned by a restricted user

Open pelepelin opened this issue 3 years ago • 12 comments

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

pelepelin avatar Dec 27 '22 22:12 pelepelin

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.

massmog avatar Jan 05 '23 08:01 massmog

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>

meisenkaiser123 avatar May 15 '23 10:05 meisenkaiser123

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

ramisedhom avatar May 27 '23 13:05 ramisedhom

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

andrsmllr avatar Jun 27 '23 15:06 andrsmllr

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

artarik avatar Nov 19 '23 11:11 artarik

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

edumotya avatar Jun 24 '24 12:06 edumotya

No solution to this problem?

xR3b0rn avatar Jul 23 '24 08:07 xR3b0rn

Same problem here.

mikegerber avatar Aug 03 '24 04:08 mikegerber

+1

NOI-William avatar Mar 11 '25 09:03 NOI-William

Yet another user here! Same problem.

rromerson avatar Jul 08 '25 16:07 rromerson

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.

LeoChenHere avatar Aug 02 '25 09:08 LeoChenHere

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.

andrsmllr avatar Nov 25 '25 20:11 andrsmllr