DEV Community

Cover image for How to Upgrade to Fedora 37 In Place on Windows Subsystem for Linux (WSL)
Jonathan Bowman
Jonathan Bowman

Posted on • Updated on

How to Upgrade to Fedora 37 In Place 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 37. 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 37, the following should do the trick:

sudo dnf system-upgrade download --releasever=37
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 37, 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 should see Reboot turned off, not rebooting.

Moment of truth: launch the upgrade

Now trigger the actual upgrade with

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

Finalization

You should now have a fresh Fedora 37 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

Again, this should not be necessary unless you were on a much earlier version of Fedora.

Then refresh and upgrade all the packages.

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

Just to be as clean as possible (you may still have processes running that are actually older versions than installed), why not restart your WSL distro. Open a Powershell window, and terminate your WSL instance. Assuming your instance is named "fedora" you can wsl -t fedora.

Then, relaunch with wsl -d fedora

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=37
export DNF_SYSTEM_UPGRADE_NO_REBOOT=1
sudo -E dnf system-upgrade reboot
sudo -E dnf system-upgrade upgrade
sudo dnf upgrade --refresh
Enter fullscreen mode Exit fullscreen mode

Enjoy your shiny new Fedora!

Keep upgrading

If you chose to upgrade to a beta or 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

If you daringly chose to use Fedora 37, for instance, upgrade as often as you like with the above command, and you will eventually (by the end of October 2022) be at release.

Top comments (7)

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

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

Collapse
 
bowmanjd profile image
Jonathan Bowman

Eureka! Thank you so much.

Collapse
 
alfonso2ff profile image
alfonso2ff

Hello how are you!
I really liked the post about installing fedora on windows 10 wsl. I did the latest update of windows w on Fedora 36 as well as your guidance on the post. I noticed the amount of applications linked to linux fedora is quite large. I'm not a big fan of command line SW all the time. as is the case from linux fedora to wsl. Question: Is there a way to enter the Fedora GUI through wsl2? Thanks for everything!

Hug,

Collapse
 
bowmanjd profile image
Jonathan Bowman

Great question! This is definitely possible, but I confess I have never done it. I would suspect that it would be similar to Ubuntu setups, but I am unsure. Perhaps others here will respond.

Collapse
 
vcald profile image
Vcald • Edited

I have followed the instructions presented here to upgrade from a working fedora 40 wsl to fedora 41.
Upgrade was fine...the only issue I have now is probably not important..still, when I launch wsl fedora I get the following error message :
Failed to connect to bus: No such file or directory
Any hint on how to solve this?
I have to add that, if I run 'dnf reinstall dbus' the problem disappears temporarily...then, after a few logins it reappears again.
Thank you very much

Collapse
 
darthjoker profile image
Darth Joker

Thank you @bowmanjd , this is a great article. It really helped me!
Just a fyi, this also works for 34 to 35.