Moving WSL to a Different Drive

wsl --list -v
 
wsl --shutdown
wsl --terminate <distro-name>

Exporting Distro

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

NOTE

For Docker it is sufficient to move docker-desktop-data. The docker-desktop will be recreated in C drive on restart even if moved it does not grow in size when using Docker so shouldn’t be a problem

Unregister the Distribution

wsl --unregister Ubuntu

Import the Distro

mkdir D:\WSL
wsl --import Ubuntu D:\WSL D:\backup\ubuntu.tar

NOTE

When Importing the image ensure that it is saved in its own directory

Install & Update WSL

wsl --list --online (View all available Disto's)
wsl --install -d <Distro>

Update WSL

wsl --update
wsl --update --rollback

WSL Information

wsl --status

Other WSL Commands

Change Distro Default User

Set Default User for Windows Subsystem for Linux Distro in Windows 10 | Tutorials

ubuntu config --default-user <username>

cd C:\User\<Username>\AppData\Local\Microsoft\WindowsApps (If WSL is not added to Environment Path)

Set Default Distro

wsl -s <distro-name> 

Launch an Distro Instance as Particular User

wsl ~ -d Ubuntu -u david

Access WSL Disto Drive from Explorer

\\wsl$\

WSLg Debugging Commands

# Set Display Variable
echo $DISPLAY
export DISPLAY=:0 
 
# Check if X11 is setup
ls -la /tmp/.X11-unix
ls -la /tmp/.X11-unix/
 
# Recreate Link if Missing
sudo rm -r /tmp/.X11-unix 
sudo ln -s /mnt/wslg/.X11-unix /tmp/.X11-unix

How can I change the location of Docker - Stack Overflow

Advanced settings configuration in WSL | Microsoft Learn