Skip to content

Migrate WSL to a different Drive

Replace Ubuntu (the OS name) with your own OS name.

OS name

wsl --list -v

Stop OS

wsl -t Ubuntu

Create a backup of OS

mkdir D:\.wsl
wsl --export Ubuntu "D:\.wsl\ubuntu.tar"

De-register OS

wsl --unregister Ubuntu

Create new OS

wsl --import Ubuntu "D:\.wsl\ubuntu" "D:\.wsl\ubuntu.tar"

Set default user

echo -e "[user]\ndefault=$(whoami)" >> /etc/wsl.conf

Set default OS

wsl --setdefault Ubuntu

References