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.
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’.
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).
Rename this file to fedora-36-rootfs.tar and move it to an easy-to-find location, such as your Documents or Downloads folder.
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:
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
To list installed distributions, type:
And to launch Fedora, you can type:
wsl -d fedora
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
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 :
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
Now, when you launch WSL, you do not have to specify the user every time.
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.
Obviously, WSL2 is not recommended for a complete desktop experience, you should try installing a distribution in a virtual machine or consider dual booting.