Skip to content

Instantly share code, notes, and snippets.

@pomelo
Created March 10, 2020 11:12
Show Gist options
  • Save pomelo/4bfe224a606b08f4e7ebc12c31fd85fd to your computer and use it in GitHub Desktop.
Save pomelo/4bfe224a606b08f4e7ebc12c31fd85fd to your computer and use it in GitHub Desktop.
Howto: Move a distro of WSL2 to another disk, and default user
# https://github.com/MicrosoftDocs/WSL/issues/412#issuecomment-501913246
# start CMD or POWERSHELL
# export current image
wsl --export Ubuntu-18.04 ./ubuntu.tar
# make destination path
mkdir E:\UbuntuVHDX
# import image
wsl --import Ubuntu18.04 E:\UbuntuVHDX ./ubuntu.tar
# start new WSL2 image by specify user
wsl -d Ubuntu18.04 --user pomelo
# get uid
id -u
# follow https://github.com/microsoft/WSL/issues/4276#issuecomment-509364493 to update registry
# HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\{MY-UUID}
# Note the `id -u` returns decimal.
# exit distro
exit
# unregister the old one
wsl --unregister Ubuntu-18.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment