This answer refers to the newer Store/UWP version of WSL. To confirm that you are using this newer version, run the following from PowerShell:
Get-AppxPackage |? { $_.Name -like "*WindowsSubsystemforLinux*" }
If you see a result, continue reading this answer. If you do not get a result, then you may be running an older release of WSL. See my older answer on how to completely uninstall that version.
For the Store/UWP version, the answer has changed:
Can WSL 2 be installed from scratch without installing WSL 1 before?
Yes, under Windows 11 22H2, a wsl --install will by default only install WSL2. To install WSL1, you must add wsl --install --enable-wsl1.
Note that the --enable-wsl1 option is not available on Windows 10, even on a fully updated system that is otherwise compatible with the newer WSP version. On Window 10 (19045.2311), WSL1 is still automatically installed and enabled with wsl --install.
What is the most secure and advisable process to remove WSL completely?
Here's the best info I have on removing everything related to WSL. This should make sure that (a) all features are removed, and (b) all disk space is reclaimed.
Uninstall
Optionally, back up existing distributions:
It sounds like you consider the existing instance a lost cause, but if you'd like to back it up for posterity, you can start with:
wsl --export <distroname> archivename.tar
Confirm all distribution names to backup via wsl -l -v.
Alternatively, copy out just the files that are important to you from the distribution to a safe place outside the distribution. Usually, this will include everything in your home directory, but also look at /var and /etc for any files you may want to keep.
If you have Docker Desktop installed, see Docker documentation for information on how to back up any Volumes, Containers, etc.
Optionally, confirm validity of backed-up distribution(s):
Of course, if the backup is important to you, then confirm that it works with a wsl --import into a new name.
Unregister existing distributions:
For each distribution found with wsl -l -v, remove it via:
wsl --unregister <distroname>
Warning: This is a destructive and irreversible operation unless you have a valid backup as above.
Identify any distribution packages (applications) installed from the Store:
Go to Settings -> Add or remove programs and look for any distributions you may have installed from the Store (Ubuntu, Debian, Alpine, openSUSE, or others). This is actually separate from the distribution you unregistered above. These packages include the Distro Launcher and rootfs that originally created your distribution (e.g. ubuntu2004.exe).
Alternatively, you can run the following command from an Administrator PowerShell (PowerShell Core is recommended):
Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss\ |
ForEach-Object {
(Get-ItemProperty $_.PSPATH) | Select-Object DistributionName,BasePath
}
This should list all of the installed Distribution packages on your system.
Then uninstall each distribution using Add/Remove Programs.
Under older Windows versions, uninstalling these packages also uninstalled the corresponding distribution, leading to some unintended data loss. It appears most recent systems require these to be removed in two separate steps, which is a good thing.
Also in Settings -> Add or remove programs, look for, and remove, any "Windows Subsystem for Linux" apps. This may include:
- Windows Subsystem for Linux: The main WSL package itself. (Note: You may not see this package under the latest release. If not, it has probably been transitioned to a System Component and can be uninstalled in the next step.)
- Windows Subsystem for Linux Update: Updates to the kernel package for older versions (in-box, that came as a Windows feature) versions of WSL.
- Windows Subsystem for Linux WSLg Preview: The WSLg feature that came with Windows 11.
Go to Settings -> System -> System Components (or, from the Windows Menu, search for System Component Settings).
If "Windows Subsystem for Linux" is in this list as a System Component, then, from PowerShell, run:
wsl.exe --uninstall
This will require Administrator elevation. The elevation dialog could pop up in the background, so be on the looking for a flashing title in the Windows Taskbar.
It might be best to reboot at this point to release any other in-use files.
Next, go to Settings -> Turn Windows features on or off.
If they are enabled, disable:
- Virtual Machine Platform
- Windows Subsystem for Linux
Windows will likely prompt to reboot.
After rebooting, confirm that all of the above items were removed successfully. At this point, any wsl command should simply return the default "install" help text.
Reinstall
The recommended way to reinstall from here is:
Open an elevated PowerShell. It is best to do this as your regular user, in an administrator elevated session, rather than as the separate Admin user.
wsl --install
By default, this will:
- Re-enable the Virtual Machine Platform
- Install the latest WSL release from the Microsoft Store. This release now includes the kernel directly, rather than requiring a separate installation step as before.
- Install the default Ubuntu distribution from the Microsoft Store
Also see wsl --help for additional installation options. For instance, you can skip the installation of a distribution at this stage or select a different distribution.