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:
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:
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:
Once initiated, the export operation will display a message such as the following:
Once completed, the export operation will display a message including the size of the exported TAR file:
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:
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:
Unregistering.
The operation completed successfully.
No comments :
Post a Comment