WSL icon indicating copy to clipboard operation
WSL copied to clipboard

/run/user/1000 owner become root when pre mount a vhdx disk before start the wsl system

Open lawrsp opened this issue 3 years ago • 1 comments

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

  1. restart windows
  2. bare mount a vhdx disk with admin powershell
    wsl.exe  --mount --partition 1 \\.\PHYSICALDRIVE$4 -o "discard,errors=remount-ro,data=ordered" --bare
    
  3. 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

lawrsp avatar Sep 14 '23 10:09 lawrsp

my solution is

  1. not load the vhdx to windows disk manager, if loaded, unload it
  2. 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

lawrsp avatar Jun 14 '24 14:06 lawrsp