Quantcast
Channel: Help & How To
Viewing all articles
Browse latest Browse all 5861

How to properly delete a Linux distro from WSL

$
0
0

WSL

Installing a Linux distro in WSL is easier than ever, but how do you properly remove one?

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.

How to completely remove a Linux distro from WSL

WSL Debian

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.

    WSL

  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.

This process should remove any associated file systems, but it's worth opening up File Explorer and having a look just to make sure. WSL file systems are easily accessed from the sidebar, and if anything is left behind you can just manually delete it.

Backing up and importing to WSL

Windows Subsystem for Linux

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.

Template: 
Rating: 
0.00

Viewing all articles
Browse latest Browse all 5861

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>