Published on

Common Settings for WSL2

Authors

Start WSL2 as the root user by default

1. Get the name of all the installed WSL distributions

wsl --list --verbose

2. Replace distro-name with the name of your WSL distribution(e.g., Ubuntu)

distro-name config --default-user root

For instance:

Ubuntu config --default-user root

General Steps for WSL Data Migration

1. Export the WSL Distribution

wsl --export Distribution-Name Export-Path.tar
  • Distribution-Name: The name of the WSL distribution to export (e.g., Ubuntu, docker-desktop, docker-desktop-data, etc)
  • Export-Path: The path where the .tar file will be saved (e.g., D:\Data\WSL_Export\<Distribution-Name>.tar)

For instance:

wsl --export Ubuntu D:\Data\WSL_Export\Ubuntu.tar

2. Unregister the current WSL distribution

wsl --unregister Distribution-Name

For instance:

wsl --unregister Ubuntu

3. Import the WSL Distribution

wsl --import Distribution-Name New-Data-Path Export-Path.tar --version 2

For instance:

wsl --import Ubuntu D:\Data\WSL_Ubuntu_Data D:\Data\WSL_Export\Ubuntu.tar --version 2