Skip to content

Instantly share code, notes, and snippets.

@mzaglia
Last active August 16, 2021 04:45
Show Gist options
  • Save mzaglia/cfac1d98c29104bcdedf85e6e6fa935f to your computer and use it in GitHub Desktop.
Save mzaglia/cfac1d98c29104bcdedf85e6e6fa935f to your computer and use it in GitHub Desktop.
WSL Change vhdx
  1. Backup current vhdx file from %LOCALAPPDATA%\Packages\<PackageFamilyName>\LocalState\ext4.vhdx to D:\ext4.vhdx (Most important step. If you can't find correct vhdx file, you shouldn't go ahead)
  2. Remove current distro, like wsl --unregister Ubuntu-20.04
  3. Reinstall distro from Microsoft Store
  4. Export and import wsl --export Ubuntu-20.04 D:\wsl.tar wsl --unregister Ubuntu-20.04 wsl --import Ubuntu-20.04 D:\Ubuntu-20.04 D:\wsl.tar
  5. Overwrite original vhdx file copy D:\ext4.vhdx D:\Ubuntu-20.04\ext4.vhdx
  6. Set default user ubuntu2004.exe config --default-user <username>

Change path in regedit Computer\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss\{randon uuid}\BasePath If you get Access Denied, change User permissions to Full controll.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment