An Interest In:
Web News this Week
- March 22, 2024
- March 21, 2024
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
Upgrade Ubuntu Version on WSL
Prerequisites
If we are using a username different than root, we need to know it running the whoami
command (WSL side):
Also we need to know the distro name and WSL version, running the wsl --list --verbose
command on PowerShell (Windows side):
Knowing the username: equiman
, the linux distribution: Ubuntu
, and confirm that we are using the WSL 2
version, we are ready to...
Backup
All next steep need to be done on PowerShell (Windows side).
First, we need to close all terminals that are using WSL, and then shut it down to avoid data corruption running the wsl --shutdown
command.
Next we are going to create a backup from our Ubuntu
linux distribution.
mkdir D:\backupwsl --export Ubuntu D:\backup\ubuntu.tar
Don't worry if you do not see progress indicators. This can take a while depending on how much data you have. Maybe it's a good idea to take a rest.
Relaunch
When the backup is finished, relaunch WSL by running the command wsl
and running these commands.
All next steep need to be done on WSL (Linux side).
Update the packages' source and update the outdated installed applications.
sudo apt updatesudo apt list --upgradablesudo apt upgrade -y
Its important to install this update manager core package this will trick the system to think there is a new LTS available and allow you to do an in-place upgrade.
sudo apt install update-manager-core
Install the new version with
sudo do-release-upgrade
If you are using an LTS version (recommended) and found that there is no new LTS version available it will show this message
Checking for a new Ubuntu releaseThere 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.
If it's not relevant to you to not use LTS versions, you can use the Prompt
to normal in the file mentioned in the message and rerun the previous command.
Another alternative is to use -d
flag added with the command
sudo do-release-upgrade -d
This is done because an upgrade to the latest LTS is not directly available till July of the year of release of the LTS. However, the -d
flag forces the command to upgrade to the latest development release, and it also considers an LTS release as a development release.
Then, accept all packages you have to download, and it will take a while depending on your network and disk speed mostly.
Finally, run the command sudo reboot
Recover
All next steep need to be done on PowerShell (Windows side).
If something goes wrong in the process, don't worry, we can restore our previous WSL disk from the backup.
Didn't You skip the backup step? right?
First, we need to unregister the Linux distribution
Beware that everything that was stored on the WSL drive will be lost, and the command won't ask for a confirmation, so make sure you backup everything you need first!
wsl --unregister Ubuntu
And then, import again on the desired path. I'll use D:
disk as an example.
mkdir D:\WSLwsl --import Ubuntu D:\WSL\ D:\backup\ubuntu.tar
By default Ubuntu will use root
as default user, to switch to our user we need to run these commands.
cd $env:USERPROFILE\AppData\Local\Microsoft\WindowsAppsubuntu config --default-user equiman
Ensure replacing
equiman
with yours.
Restart WSL running wsl
command and it's done.
Thats All Folks!
Happy Coding
Original Link: https://dev.to/equiman/upgrade-ubuntu-version-on-wsl-3h10
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To