Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registry details not preserved during distro export/import... #28

Open
mwarrenus opened this issue Aug 20, 2021 · 0 comments
Open

Registry details not preserved during distro export/import... #28

mwarrenus opened this issue Aug 20, 2021 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@mwarrenus
Copy link

mwarrenus commented Aug 20, 2021

Bug
WSL stores information about distros in the registry under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\{your-distro-uuid}; however, wsl --import and wsl --export do not save/restore these keys. Can move-wsl preserve this information?

Example
After running the command line

wsl --export Alpine - | wsl --import Alpine1 e:\wsl\Alpine1 -

to quickly copy the Alpine distro, the new registry entry for the Alpine1 copy has only a minimal set of keys and its DefaultUid has been changed to 0 (root):

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\{your-alpine1-disto-uuid}]
"State"=dword:00000001
"DistributionName"="Alpine1"
"Version"=dword:00000002
"BasePath"="\\\\?\\E:\\wsl\\Alpine1"
"Flags"=dword:00000007
"DefaultUid"=dword:00000000

The original Alpine distro has more details including a KernelCommandLine and DefaultEnvironment as well as DefaultUid=dword:000003e8 (1000) (regular user):

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\{your-alpine-distro-uuid}]
"State"=dword:00000001
"DistributionName"="Alpine"
"Version"=dword:00000001
"BasePath"="C:\\Users\\YourUserName\\AppData\\Local\\Packages\\36828agowa338.AlpineWSL_my43bytk1c4nr\\LocalState"
"Flags"=dword:00000007
"DefaultUid"=dword:000003e8
"PackageFamilyName"="36828agowa338.AlpineWSL_my43bytk1c4nr"
"KernelCommandLine"="BOOT_IMAGE=/kernel init=/init"
"DefaultEnvironment"=hex(7):48,00,4f,00,53,00,54,00,54,00,59,00,50,00,45,00,3d,\
  00,78,00,38,00,36,00,5f,00,36,00,34,00,00,00,4c,00,41,00,4e,00,47,00,3d,00,\
  65,00,6e,00,5f,00,55,00,53,00,2e,00,55,00,54,00,46,00,2d,00,38,00,00,00,50,\
  00,41,00,54,00,48,00,3d,00,2f,00,75,00,73,00,72,00,2f,00,6c,00,6f,00,63,00,\
  61,00,6c,00,2f,00,73,00,62,00,69,00,6e,00,3a,00,2f,00,75,00,73,00,72,00,2f,\
  00,6c,00,6f,00,63,00,61,00,6c,00,2f,00,62,00,69,00,6e,00,3a,00,2f,00,75,00,\
  73,00,72,00,2f,00,73,00,62,00,69,00,6e,00,3a,00,2f,00,75,00,73,00,72,00,2f,\
  00,62,00,69,00,6e,00,3a,00,2f,00,73,00,62,00,69,00,6e,00,3a,00,2f,00,62,00,\
  69,00,6e,00,3a,00,2f,00,75,00,73,00,72,00,2f,00,67,00,61,00,6d,00,65,00,73,\
  00,3a,00,2f,00,75,00,73,00,72,00,2f,00,6c,00,6f,00,63,00,61,00,6c,00,2f,00,\
  67,00,61,00,6d,00,65,00,73,00,00,00,54,00,45,00,52,00,4d,00,3d,00,78,00,74,\
  00,65,00,72,00,6d,00,2d,00,32,00,35,00,36,00,63,00,6f,00,6c,00,6f,00,72,00,\
  00,00,00,00

--
ASCII version of DefaultEnvironment:
HOSTTYPE=x86_64
LANG=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
TERM=xterm-256color

Issue #3974 from the microsoft/WSL repository has more details about how to workaround this issue in Powershell.

Script version:

  • [ x ] Bash
  • [ x ] Powershell
  • [ x ] Batch

Edit: How to find values
These commands provide values for DefaultUid, KernelCommandLine, and DefaultEnvironment:

@echo off
SET WSL_NAME=%~1
wsl -d %WSL_NAME% -e id -u
wsl -d %WSL_NAME% -e cat /proc/cmdline
wsl -d %WSL_NAME% sh -c "env |  grep -v -E '^(PATH|NAME|HOME|USER|LOGNAME|SHELL|WSL_DISTRO_NAME|WSLENV|WT_SESSION|WT_PROFILE_ID|SHLVL|PWD|DSISPLAY|WSL_INTEROP|DISPLAY|WAYLAND_DISPLAY|PULSE_SERVER|_)='"
echo|set /p ="PATH="
wsl -d %WSL_NAME% sh -c "printenv PATH | sed 's/:\/mnt\/.*//g'"
@mwarrenus mwarrenus added the bug Something isn't working label Aug 20, 2021
@pxlrbt pxlrbt added enhancement New feature or request help wanted Extra attention is needed and removed bug Something isn't working labels Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants