Skip to content

Instantly share code, notes, and snippets.

@oliverlabs
Created April 25, 2023 14:44
Show Gist options
  • Select an option

  • Save oliverlabs/729eec680942716978fdfe413e265980 to your computer and use it in GitHub Desktop.

Select an option

Save oliverlabs/729eec680942716978fdfe413e265980 to your computer and use it in GitHub Desktop.
WSL Image Backup and Migration
#To move to a custom location
#Terminate specific distribution
wsl -t Ubuntu
#Shutdown WSL (all)
wsl --shutdown
#export
wsl --export Ubuntu s:\scratch\ubuntuwsl.tar
#OR
wsl --export Ubuntu s:\scratch\ubuntuwsl.vhdx #much faster
#Then
wsl --unregister Ubuntu
#Import to location of your choice
wsl --import Ubuntu s:\images\Ubuntu s:\scratch\ubuntuwsl.vhdx
wsl --list --verbose
#Can change the default
wsl --set-default Ubuntu
#Start and connect to distribution
wsl -d Ubuntu
#To avoid entering password at every sudo
sudo visudo
<#
Add to end of file
[$USERNAME] ALL=(ALL) NOPASSWD:ALL
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment