3

I was using Windows 10 version 1909 yesterday. I had WSL enabled with Ubuntu 18.04 installed.

Now I have updated to Windows 10 version 2004. How do I update to WSL 2 the cleanest way with no residue from older version?

I'm looking at this guide https://docs.microsoft.com/en-us/windows/wsl/install-win10#update-to-wsl-2 it doesn't seem to apply to my case since I already have WSL and an existing Linux distro (Ubuntu 18.04).

Do I need to uninstall Ubuntu 18.04 or WSL or both of them before updating?

My end goal is to have WSL2 with the latest Ubuntu in my windows and preferably no residue from older versions.

3 Answers 3

0

Now I have updated to Windows 10 version 2004. How do I update to WSL 2 the cleanest way with no residue from older version?

You run a single command to upgrade the WSL 1 Ubuntu instance to a WSL 2 Ubuntu instance.

Do I need to uninstall Ubuntu 18.04 or WSL or both of them before updating?

It’s not necessary to uninstall the current Ubuntu WSL instance. You simply upgrade the Ubuntu 18.04 instance to WSL 2 by running the following command.

wsl --set-version Ubuntu 2

My end goal is to have WSL2 with the latest Ubuntu in my windows and preferably no residue from older versions.

How you upgrade Ubuntu 18.04 to Ubuntu 20.04 is well documented but separate from the process of upgrading the WSL instance to WSL 2.

It should be enough, to run the following two commands, in order to upgrade 18.04 to 20.04.

If you run into problems you can simply uninstall the current Ubuntu 18.04 instance and install Ubuntu 20.04 from the Microsoft Store.

sudo apt-get upgrade

sudo do-release-upgrade
0
0

Well you dont have to Uninstall anything, you can use the --set version argument to change the version for your linux distro, so for your case it would be:

wsl  --set-version Ubuntu-18.04

after it has finished running, you can use the following commands to check whether it has updated

wsl -l -v

check the version column for the WSL Version

-2

You can use below PowerShell script

# Uninstall Linux distributions installed on asset 

$packages = Get-AppxPackage -AllUsers | Where-Object {($_.Name -like '*Ubuntu*' -or $_.Name -like '*Debian*' -or $_.Name -like '*Fedora*' -or $_.Name -like '*Kali*' -or $_.Name -like '*Suse*' -or $_.Name -like '*Arch*' -or $_.Name -like '*Alpine*' -or $_.Name -like '*openSUSE*') -and $_.Name -notlike '*Microsoft.Windows.Search*'} 

if ($packages.Count -gt 0) { 

    Write-Host "Linux distributions found:" 

    $packages | Select-Object -Property Name, Publisher, Version | Write-Host 

    foreach ($package in $packages){ 

    Remove-AppPackage $package   

    }  

    Write-Host "Linux distributions removed completely with their files" 

} else { 

    Write-Host "No Linux distributions found." 

}   
1
  • 1
    Welcome to SU. This appears to be quite a nifty way of uninstalling a WSL Linux distribution. However this doesn't answer the question. It isn't "How do I uninstall", it's "Should I uninstall". You can edit the question to add this. This is an old question with 2 answers, both stating that uninstallation isn't necessary. If you disagree, you should add some sources for the claim so others can verify whether it's correct. Apr 10, 2023 at 12:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .