How to completely remove a Linux distro from WSL – Windows Central

Npressfetimg 2576.png

In recent times, installing the Windows Subsystem for Linux (WSL) on Windows 10 and Windows 11 has become much easier. We’re at the point now where you can either install it from the Microsoft Store or enter a single command in the terminal to be on your merry way.

One of the many benefits of WSL is that you can set up a full Linux distro and integrate it into your Windows workflow without fear of breaking anything important on your PC. It’s a virtual machine, but one that interacts with your Windows installation, and if anything should go wrong you can simply destroy it and start again.

But how do you actually remove a Linux distro installed in WSL? On the face of things, you might think you just have to uninstall the “app” for the particular distro you installed, but that’s only half of the battle. Here’s how to completely remove it.

VPN Deals: Lifetime license for $16, monthly plans at $1 & more

How to completely remove a Linux distro from WSL

Indeed you can simply right-click and uninstall Ubuntu, Debian, or any of the other Linux distros you might have set up on WSL. Installing them is as easy as downloading from the Microsoft Store, and removing them is as easy as any other Store app. Alternatively, you can do the same with winget in the terminal if you’re a fan of using the Windows Package Manager.

But this doesn’t completely remove all traces. Data and the file system created will be left behind, so for that, you need to instruct WSL to remove it in the terminal. So do the uninstalling of the app second, ideally.

Here’s what you need to do.

  1. Open up PowerShell.
  2. To get the exact name for the distro you want, enter wsl -l -v.

    Source: Linux

  3. Enter into the terminal wsl --unregister <distro name>.

The unregister option will tell WSL to completely destroy all traces of the file system and any data contained within it. So, for example, if you wanted to remove an installation of Debian your command would look like this:

wsl --unregister Debian

It’s case sensitive, too, and has to be exact, which is why it’s a good idea to run Step Two first. Ubuntu, for example, has a number of different versions, and you may well need to be specific to a version number, such as Ubuntu 20.04. Though this will depend on which package you installed in the first instance

Backing up and importing to WSL

While WSL can be disposable, it’s also a good idea to back up your installations so if you do get rid of one you can get back to where you were a little easier.

Backing up is a pretty straightforward process that involves exporting to a .tar file. Our guides on exporting and importing Linux installs in WSL will take you through the process step by step, but the main commands you need are as follows:

wsl --export <distro> <filename.tar>
wsl --import <distro> <install location> <filename> 

The process doesn’t take too long, and it’s particularly useful if you plan on making frequent changes to your WSL installs.

Source: https://www.windowscentral.com/how-completely-remove-linux-distro-wsl


Leave a Reply

Your email address will not be published. Required fields are marked *