DEV Community

loading...
Cover image for How to Upgrade Fedora In Place on Windows Subsystem for Linux (WSL)

How to Upgrade Fedora In Place on Windows Subsystem for Linux (WSL)

bowmanjd profile image Jonathan Bowman Updated on ・3 min read

How to upgrade from Fedora 33 to Fedora 34 on Windows Subsystem for Linux (WSL)

The time has once again arrived to upgrade Fedora. As detailed in another article, I installed Fedora on WSL 2. Now I want to upgrade to Fedora version 34. I could do a clean install of course, using the steps detailed in that article, but I want to upgrade in place.

How do we do that?

Here are the steps I use, based on official Fedora instructions.

Backup first

Just in case, yes?

First, clean up downloaded packages, etc. within Fedora:

sudo dnf clean all
Enter fullscreen mode Exit fullscreen mode

Then, exit WSL and export the whole installation to a tarball (this assumes your distro name is "fedora"):

wsl --export fedora $HOME\Downloads\fedora-wsl.tar
Enter fullscreen mode Exit fullscreen mode

You may want a different folder than Downloads; specify the location you desire.

Depending on what packages you installed, it may be as small as a quarter GB, or it could be far larger. You could gzip it if you want the storage size to be even smaller. Next time you want to start fresh, you can do something like this:

mkdir $HOME\wsl\freshfedora
wsl --import freshfedora $HOME\wsl\freshfedora $HOME\Downloads\fedora-wsl.tar
Enter fullscreen mode Exit fullscreen mode

Begin the upgrade: freshen up

It is important to have a refreshed package index, and upgrade all packages to the latest. You can do so with

sudo dnf upgrade --refresh
Enter fullscreen mode Exit fullscreen mode

Install the upgrade system

We will need DNF System Upgrade in order to make the leap, so let's install it now.

sudo dnf install dnf-plugin-system-upgrade
Enter fullscreen mode Exit fullscreen mode

Download new release packages

To prepare and download for a system upgrade to Fedora 34, the following should do the trick:

sudo dnf system-upgrade download --releasever=34
Enter fullscreen mode Exit fullscreen mode

This will take a bit of time.

Yes, you should feel fine about importing the new GPG for Fedora 34, so you can answer "y" to that.

Reboot?

If using WSL, this is where it gets a little strange, but only a little.

I first set a flag to indicate reboots are not necessary.

export DNF_SYSTEM_UPGRADE_NO_REBOOT=1
Enter fullscreen mode Exit fullscreen mode

Not sure how necessary that is, but it doesn't hurt. We can restart WSL ourselves, if we need to, but I have not found that to be required. If you are doing this on a full Fedora system (not WSL), please do not set this flag; you need to do an actual reboot.

Now we trigger the update, strangely, with the upgrade and reboot command (pass the -E flag to sudo in order to utilize the DNF_SYSTEM_UPGRADE_NO_REBOOT variable defined earlier):

sudo -E dnf system-upgrade reboot
Enter fullscreen mode Exit fullscreen mode

You will get some systemd errors, such as System has not been booted with systemd as init system (PID 1). Can't operate. and Failed to connect to bus: Host is down. You can safely ignore these.

Moment of truth: launch the upgrade

Hit Enter to get a prompt again. Then trigger the actual upgrade with

sudo dnf system-upgrade upgrade
Enter fullscreen mode Exit fullscreen mode

Yes, we will get those systemd errors again, but no worries. You can trust that the right stuff is happening.

Finalization

You should now have a fresh Fedora 34 system.

In case you upgraded from Fedora 32 or earlier, the RPM database backend has changed somewhat. Refresh it with

sudo rpmdb --rebuilddb
Enter fullscreen mode Exit fullscreen mode

Then refresh and upgrade all the packages.

sudo dnf upgrade --refresh
Enter fullscreen mode Exit fullscreen mode

Reference: all the steps in one place

For your reference, here are all the steps in one block:

sudo dnf upgrade --refresh
sudo dnf install dnf-plugin-system-upgrade
sudo dnf system-upgrade download --releasever=34
export DNF_SYSTEM_UPGRADE_NO_REBOOT=1
sudo dnf system-upgrade reboot
sudo dnf system-upgrade upgrade
sudo dnf upgrade --refresh
Enter fullscreen mode Exit fullscreen mode

Enjoy your shiny new Fedora!

Keep upgrading

Even if you have a prerelease, there should be no need to reinstall. Just keep upgrading, as often as you like; the process is pretty seamless:

sudo dnf upgrade
Enter fullscreen mode Exit fullscreen mode

Using Fedora 34, upgrade as often as you like with the above command, and you will eventually (by the end of April 2021) be at release.

Discussion (3)

pic
Editor guide
Collapse
brnvrn profile image
Bruno Vernay

Hi
I suspect your variable "DNF_SYSTEM_UPGRADE_NO_REBOOT=1" is not taken into account when running sudo.
This is all I have running these:
➜ dnf system-upgrade reboot
Reboot turned off, not rebooting.

I did not have your error message. Anyway, I upgraded, thanks :-)

Could have used

  • "sudo DNF_SYSTEM_UPGRADE_NO_REBOOT=1 dnf system-upgrade reboot"
  • or "sudo -E dnf system-upgrade reboot"
Collapse
bowmanjd profile image
Jonathan Bowman Author

I have updated the article according to your good instructions. Again, many thanks!

Collapse
bowmanjd profile image
Jonathan Bowman Author

Eureka! Thank you so much.