Fedora in Windows Subsystem for Linux (WSL)

Fedora

This guide is a result of me wanting to run Fedora Linux in Windows Subsystem for Linux and not seeing it in the Microsoft Store like how Ubuntu is available there.

I found that Windows Subsystem for Linux can run any Linux distro, it just takes a little bit of work to get it going.

This is me documenting how I did it for my future-self who may want to do this on a different machine. If this doc helps someone else too, that’s a win!

Prerequisites

You’ll need to have Windows Subsystem for Linux installed. So follow these instructions first.

Download Stuff

In order to get Fedora installed, we will need the rootfs for Fedora. To get that, download the latest container image from here.

It will be in the a directory like:

https://kojipkgs.fedoraproject.org/packages/Fedora-Container-Base/Fedora_Version/YYYYMMDD.n/images

Example:

https://kojipkgs.fedoraproject.org/packages/Fedora-Container-Base/36/20220719.0/images/

The file that needs to be downloaded will have filename in this format:

Fedora-Container-Base-Fedora Version-YYYYMMDD.n.x86_64.tar.xz

Example:

https://kojipkgs.fedoraproject.org/packages/Fedora-Container-Base/36/20220719.0/images/Fedora-Container-Base-36-20220719.0.x86_64.tar.xz

Get rootfs

Decompress the .xz file using 7zip.

Untar the resulting tar file and it will result in some files plus a directory with a named that is a long string.

Example:

59135f619d850a13d26257f4c6633afdb6cac410aefec77b12709f30c5cca602

Inside that directory is a file named “layer.tar”. This is the rootfs for Fedora that we will be using.

Windows Subsystem for Linux

Create a directory where Fedora’s filesystem will be installed to.

Example:

C:\WSL\Fedora

Run wsl import to create a new Fedora distribution:

wsl --import Fedora path_to_install_location location_of_fedora_basefs

Example:

wsl --import Fedora C:\WSL\Fedora C:\Temp\layer.tar

Get Fedora Running

Start up Fedora (from Powershell):

wsl -d Fedora

Update the system:

dnf update

The rootfs does not have much, so we will need to have some minimal set of tools for it to be useful. I used package groups to make this process easier.

List package groups:

dnf grouplist

Install the group you want:

dnf groupinstall "group"

Example (I chose the “Minimal Install” and will add what I need as I go):

dnf groupinstall "Minimal Install"

Do Your Linux Stuff

Don’t forget to add a user and not run around as root.

That’s it! Easy, easy.