Skip to content

Instantly share code, notes, and snippets.

@sanyer
Last active March 7, 2024 05:31
Show Gist options
  • Save sanyer/0d25dbf8e57faaa7358c46cfb746da82 to your computer and use it in GitHub Desktop.
Save sanyer/0d25dbf8e57faaa7358c46cfb746da82 to your computer and use it in GitHub Desktop.
Useful WSL commands

Useful WSL commands

List distributions

wsl --list --verbose --all

Import distribution

wsl --import docker-desktop-data .\wsl\data "C:\Program Files\Docker\Docker\resources\wsl\wsl-data.tar" --version=2  # import clean docker distribution

Unregister distribution

wsl --unregister podman-machine-default

Export distribution

wsl --export podman-machine-default E:\Workspace\wsl\podman-machine-default\podman-machine-default.tar

Move WSL data volume

ls $env:LOCALAPPDATA/Docker/wsl

        Directory: C:\Users\sanyer\AppData\Local\Docker\wsl

    Mode                 LastWriteTime         Length Name
    ----                 -------------         ------ ----
    d----           23-Apr-22    22:27                data
    d----           07-Jul-22    23:32                distro

wsl -l -v
wsl --shutdown
wsl --export docker-desktop-data .\docker-desktop-data.tar
wsl --unregister docker-desktop-data
wsl --import docker-desktop-data .\wsl\data ".\docker-desktop-data.tar" --version=2
# Optimize-VHD -Path .\wsl\data\ext4.vhdx -Mode Full  # works only if Hyper-V Platform is installed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment