WSL
WSL copied to clipboard
/run/user/1000 owner become root when pre mount a vhdx disk before start the wsl system
updated:
Windows Version
10.0.22621.2283
WSL Version
1.2.5.0
Are you using WSL 1 or WSL 2?
- [X] WSL 2
- [ ] WSL 1
Kernel Version
5.15.90.1
Distro Version
Ubuntu 22.04
Repro Steps
- restart windows
- bare mount a vhdx disk with admin powershell
wsl.exe --mount --partition 1 \\.\PHYSICALDRIVE$4 -o "discard,errors=remount-ro,data=ordered" --bare - start ubuntu and check /run/user/1000
Expected Behavior
it should owned by the user (id 1000) not root (id 0)
Actual Behavior
➜ ~ cd /run/user
➜ user ll
total 0
drwxr-xr-x 2 root root 40 Sep 14 18:01 1000
➜ user
my solution is
- not load the vhdx to windows disk manager, if loaded, unload it
- direct mount to wsl, like:
wsl.exe -d Ubuntu --mount --vhd xxxxxxx --bare
sometimes before , if the vhdx file is not on disk C:, the step 2 would fail. That's why I need my old mount steps. But after some updates, it can directly mount the vhd, and there is no permission problems by these steps, so I will close this issue