Friday, September 19, 2025

WSL: Backing Up and Deleting a Distro

Before deleting a WSL distro and , say, upgrading to a new version**,** it is often wise to back up the existing distro. This blog covers the steps to perform this task.

Step 1: List Installed Distros

From a PowerShell console run the following:

wsl -l -v

This will show you the name, version, and state of each distro. One of my WSL instances shows the following when wsl -l -v is run:

  NAME                   STATE           VERSION
* docker-desktop         Stopped         2
  Ubuntu-22.04           Stopped         2
  docker-desktop-data    Stopped         2
  Ubuntu-24.04           Running         2

For this example, the distro Ubuntu-22.04 will be backed up and then deleted.

Step 2: Export the Distro (Backup)

The wsl command’s --export option allows a backup of a distro to be saved to a file in TAR format. The command is as follows for my distro, Ubuntu-22.04:

wsl --export Ubuntu-22.04 C:\Backups\20250921Ubuntu-22.04.tar

Once initiated, the export operation will display a message such as the following:

Export in progress, this may take a few minutes.

Once completed, the export operation will display a message including the size of the exported TAR file:

Export in progress, this may take a few minutes. (1167 MB)

The backup TAR file can be imported later using the wsl command. The exporting process can take several minutes, unlike deleting a distro which is instantaneous.

Step 3: Delete the Distro

The distro is backed up, so it can safely be deleted as follows with wsl:

wsl --unregister Ubuntu-22.04

Although the command-line option is --unregister, it completely deletes the distro from WSL. No warning prompt will be given. The command just runs nearly instantly:

PS C:\blogs\wslscratchpad> wsl --unregister Ubuntu-22.04
Unregistering.
The operation completed successfully.



No comments :

Post a Comment