WSL2 – Install Fedora on Windows 10/11

WSL2 or Windows Subsystem for Linux is a tool developed by Microsoft with which you can install and run any Linux distribution without having to install any virtual machine software or dual booting at all. With version 2, you can even run Linux native graphical applications. WSL2 offers a lot of distributions including Ubuntu, Debian, and SUSE Linux. And to install Fedora, we have to use a bit of a workaround by using the rootfs of Fedora.

Also read: Windows Terminal – A better way to manage your WSL instances

Install/Enable WSL2 on Windows

Now, WSL version 2 is installed in Windows 11 by default, but you have to enable it before utilizing this feature. To do this, search ‘Turn Windows Features on or off‘ from the start menu and enable ‘Windows Subsystem for Linux’.

Turn On Windows Subsystem For Linux
Turn On Windows Subsystem For Linux

If you are on Windows 10 version 21H2, OS Build 19044.1682 or higher, only the WSL version 1 is installed, and you have to download a kernel for WSL2 from the Microsoft website. Make sure that you are running WSL2 by typing the following command in your PowerShell application :

wsl --set-default-version 2

If you are running an older version of Windows, then you can enable WSL2 by typing the following commands in the PowerShell:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux,VirtualMachinePlatform -All

Restart your PC after applying the changes.

Download the RootFS file for Fedora

Visit the official Fedora container base website and obtain the correct rootfs (.xz file) for your Machine, depending upon your architecture (Most probably x86_64). As of now, there haven’t been successful Fedora 36 builds lately, so I’m using this Fedora 37 file as an example.

Download the extracted file using any extractor such as 7zip (or WinRAR), and in the extracted folder, you will once again find a tar file, extract it again till you find a file with the name layer.tar (This is your RootFS).

Keep Extracting Till You Finnd The Layer Tar File
Keep Extracting Till You Find The Layer Tar File

Rename this file to fedora-36-rootfs.tar and move it to an easy-to-find location, such as your Documents or Downloads folder.

Installing Fedora

First, open the ‘PowerShell‘ application and then create a folder where you will install your Fedora instance. For example, to make a folder in your Home folder, type:

mkdir $HOME\wsl\fedora

Now, assuming that you have your RootFS file in your Downloads folder, you can type the following command :

wsl --import fedora $HOME\wsl\fedora $HOME\Downloads\fedora-36-rootfs.tar
Installing Fedora On WSL2
Installing Fedora On WSL2

To list installed distributions, type:

wsl -l

And to launch Fedora, you can type:

wsl -d fedora

Post-Installation Tweaks

First, perform an upgrade to get all the latest packages, type:

sudo dnf update

You will notice that Fedora is logged in as root by default, and that is not safe, so let’s create a user first, so type the following commands to install the required tools:

sudo dnf install -y util-linux passwd cracklib-dicts
Install The Required Packages On Your WSL2
Install The Required Packages On Your WSL2

Let’s create a new user now, type the following command:

useradd -G wheel username

Change ‘username’ to your desired username. And to add a password, type :

passwd username
Adding A New User To Fedora
Adding A New User To Fedora

Now, close the PowerShell window and launch it again and try to log in with the newly created username :

wsl -d fedora -u username

It would be amazing if Windows log you into your Fedora instance as this newly created user by default rather than the root itself, right? So let’s make this a default behavior, type the following in your Bash Shell :

printf "\n[user]\ndefault = username\n" | sudo tee -a /etc/wsl.conf
Make A Defaulot User In Fedora On WSL2
Make A Default User In Fedora On WSL2

Now, when you launch WSL, you do not have to specify the user every time.

Summary

A Fedora Spin edition is available on the Windows store, but it is not free (free as in Beer, not Free as in Freedom), therefore we had to use a workaround for this distribution. Other than that, you can easily install other distributions such as Debian, Ubuntu, or SUSE without having to worry about the RootFS workaround.

WSL2 is not recommended for a complete desktop experience, you should try installing a distribution in a virtual machine or consider dual booting.

What is Fedora Remix for WSL?

Fedora Remix for WSL is a version of the Fedora Linux distribution that is specifically tailored for running within the Windows Subsystem for Linux (WSL) on Windows.

How can I install Fedora Remix for WSL on Windows?

You can install Fedora Remix for WSL by downloading it from the Whitewater Foundry GitHub page or from the Microsoft Store, following the official release for WSL.

What are the benefits of using Fedora on WSL?

Using Fedora on WSL allows users to leverage the power of Fedora Linux within the Windows environment, enabling them to access Fedora tools and features seamlessly.

Can Fedora on WSL be used for enterprise server configurations?

Yes, Fedora on WSL can be utilized for enterprise server configurations, offering a stable and secure environment for running server applications.

What other Linux distributions are available for WSL besides Fedora?

Other Linux distributions available for WSL include Kali Linux, Ubuntu 18.04, Ubuntu 22.04 LTS, Oracle Linux 7.9, Oracle Linux 8.7, and Oracle Linux 9.1, among others.

How can I configure Fedora Remix for WSL to suit my specific needs?

You can configure Fedora Remix for WSL using the terminal and package manager to customize the installation according to your preferences and requirements.