Skip to content

Instantly share code, notes, and snippets.

@otaviog
Created July 22, 2024 14:00
Show Gist options
  • Save otaviog/eabdbd82d122b80f32fc8bd13c7461b4 to your computer and use it in GitHub Desktop.
Save otaviog/eabdbd82d122b80f32fc8bd13c7461b4 to your computer and use it in GitHub Desktop.
WSL import/export commands

WSL export/import cheat sheet

Reference: Setting up multiple WSL distribution instances

List distros

\> wsl --list
Windows Subsystem for Linux Distributions:
docker-desktop (Default)
docker-desktop-data
Ubuntu-22.04

Export

\> wsl --export Ubuntu-22.04 c:\WslImages\ubuntu-base.tar

Import

wsl wsl --import

\> wsl --import Ubuntu-DS c:\WslImages\Ubuntu-DS c:\WslImages\ubuntu-base.tar

Start the new distro

\> wsl -d Ubuntu-DS -u otavio

Set the default user:

Inside the new distro bash:

$ sudo tee -a /etc/wsl.conf <<EOF
[user]
default=otavio
EOF

Or this from powershell

\> Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName | Where-Object -Property DistributionName -eq Ubuntu-DS  | Set-ItemProperty -Name DefaultUid -Value 1000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment