I'm new to WSL2-Ubuntu. My computer already had preisntalled the 20.04 version, but I saw there's already the 22.04 version, so I was wondering if it was worthy to have the new one. If so, how can I upgrade it?
6 Answers
Short-answer:
In general, the process for upgrading Ubuntu on WSL is pretty much the same as from a "normal" Ubuntu CLI now:
sudo apt update && sudo apt full-upgrade
# restart Ubuntu
sudo do-release-upgrade
Explanation:
Side-note: I recommending reading this question and my answer for some background information about why the Microsoft Store version won't upgrade an existing Ubuntu/WSL release.
if it was worthy to have the new one
Since it's a brand new install anyway, I'd recommend going ahead and upgrading now, yes. Several reasons:
While no release is ever "perfect", 22.04 has been out for long enough now to reach the 22.04.1 milestone. That's important, because Canonical always waits for the first point release to move an LTS release into the "stable" channel. Prior to that, even though 22.04 was released in April, it was still considered a "development" release.
Eventually, you'll need to upgrade anyway. That "eventually" may be a long time down the road, since 20.04 will be supported for almost 3 more years, but you'll ultimately get 2 more years of support (from today) on 22.04 than you will on 20.04.
It's always easier to upgrade when you have fewer packages (especially anything from a PPA) on the system. Ubuntu upgrades are typically fairly painless, but the more you have installed, the more chance (even if still small) that something will require manual intervention on your part.
So yes, it's a good idea to go ahead and upgrade.
if so, how can I upgrade it?
There are two ways to go about this:
Delete and reinstall
First, if you really haven't starting using it yet, and are willing to just "delete and reinstall", you can go ahead and directly install 22.04. At some point, I would expect that the "Ubuntu" in the Store will move to 22.04, but as mentioned in the linked post, you still won't be able to use it to "upgrade" an existing distribution. For that reason, at least for the moment, use the "Ubuntu 22.04" release in the Store:
To remove the existing distribution (of course, this is a destructive operation -- All data inside Ubuntu will be remove), from PowerShell:
wsl -l -v # Confirm the distribution name and adjust below if needed wsl --unregister UbuntuThen install or upgrade the "Ubuntu 22.04" release from the Microsoft Store.
After installing from the Store, you can either launch it, or from PowerShell:
ubuntu2204.exe install --ui=noneThank you @Blair, for pointing out in this answer the error in my previous instructions. And thank you @r4v3n6, for pointing out in a comment on this answer that I made yet another stupid mistake when attempting to fix the first error.
This will take a few seconds, ask for your username and password, and complete. Your Ubuntu distribution under WSL should now be 22.04.
"Normal" 22.04 upgrade from 20.04
Set aside several hours where you won't need WSL. LTS upgrades takes a while.
First, make sure your 20.04 installation is up-to-date:
sudo apt update && sudo apt full-upgradeClose down Ubuntu on WSL, and from PowerShell:
wsl -l -v # Confirm the distribution name and adjust below if needed wsl --terminate UbuntuRestart Ubuntu and:
sudo do-release-upgradeThere will be some user interaction required fairly early in the upgrade, IIRC. When complete, exit the upgrade screen session, restart Ubuntu again as above, and you should be good-to-go.
Note: Several prior versions required that you remove the
snapdpackage before upgrading. In several tests now on my own distributions, this no longer appears to be necessary for the 20.04 -> 22.04 upgrade. However, some users have since reported this issue going from 22.04 -> 24.04 as well. If you do get an error when upgrading, it might be useful to trysudo apt remove snapdand then try again.
After upgrading (for either method)
After upgrading, there are a few "annoyances" in 22.04 when running on WSL that you can easily correct. See:
- landscape-sysinfo.cache: Permission denied when I start Ubuntu 22.04 in WSL
- Ubuntu 22.04 LTS on WSL: "Failed to retrieve available kernel versions"/"Failed to check for ...
I can't recall if either or both of these are present after an upgrade, but I know they are in the "stock" 22.04 WSL install.
- 22,082
WSL2 install multiple Ubuntu instances
This is another option in addition to the regular upgrade approach mentioned at: https://askubuntu.com/a/1428481/52975 and can be useful if you want to keep both Ubuntus around.
List all distros that you can install from a Command Prompt:
wsl --list --online
The list contained the desired Ubuntu-22.04, so we can install it with:
wsl --install -d Ubuntu-22.04
It is also possible to install it on a GUI with the Windows Store, just search for "Ubuntu 22.04" and pick the Canonical provided item.
To get a shell into the newly installed Ubuntu-22.04 container run:
wsl -d Ubuntu-22.04
or to set it as the default container:
wsl --setdefault Ubuntu-22.04
after which running just:
wsl
will use Ubuntu-22.04 by default.
Related: https://stackoverflow.com/questions/51584765/how-do-you-install-multiple-separate-instances-of-ubuntu-in-wsl For multiple instances of the same distro version it is a bit more annoying, but possible with --export.
- 31,312
I followed @NotTheDroid's answer, which helped (and was appreciated), but didn't completely work. Many thanks - appreciate the post, but perhaps the process changed after some update? After following them, I ended up with Ubuntu 20.04 instead of Ubuntu 22.04.2
I selected "Ubuntu 22.04.2 LTS" from the MS store, but after following the steps as written, ended up with Ubuntu 20.04 again.
Only when I:
Again deleted the Ubuntu installation from WSL as described in Step 1
Disregarded this part from Step 2:
I recommend that you do not click "Open" after installing from the Store.'
Instead of Step 3, used the Open option in the Microsoft Store to install did I actually get Ubuntu 22.04.
- 22,082
- 81
- 1
- 1
Warning! The following will put you at 24.04!
I'm new here so I can't just comment on @NotTheDroid's fantastic answer. After following the steps the installation failed somewhere along the way. When WSL restarted I was still at 20.04. Retracing my steps only produced the following message:
Checking for a new Ubuntu release There is no development version of an LTS available. To upgrade to the latest non-LTS development release set Prompt=normal in /etc/update-manager/release-upgrades.
I found two key excellent instructions that got me past this and kept me in the development version with all my configurations intact. Source: https://dev.to/equiman/upgrade-ubuntu-version-on-wsl-3h10
After these commands:
sudo apt update
sudo apt list --upgradable
sudo apt upgrade -y
Run sudo apt install update-manager-core
Then sudo do-release-upgrade -d
Note the '-d' as the subtle difference from instructions in other answers.
I also appreciated the source's instructions to backup before the upgrade. Probably a good idea.
step1:
sudo vim /etc/update-manager/release-upgrades
Make sure Prompt=lts in the bottom line. If it is normal or never, no update will be detected. If it is lts, use:wq to save and exit.
step2:
Upgrade system components and check for software updates
sudo apt update
Update software
sudo apt upgrade -y
Update release version
sudo do-release-upgrade
- 31
Just install from MS shop. It should (at least in my case it did) upgrade from 20.04 to 22.04.
- 101