I’ve used Fedora as my primary OS since it’s earliest days when I found Fedora Core 1 installed on analysis computers in the astronomy offices of the Virginia Tech Physics Department. Fast forward… oh, a rather long time… and now Linux, including Fedora and other flavors, can run inside Windows using the Windows Subsystem for Linux (WSL).
The following steps will get Fedora 33 running on WSL. In my case, I set this up using a Windows 10 virtual machine in VirtualBox that was running on a Fedora 31 host. I had a little trouble, specifically:
1. I initially used WSL 1.0 because WSL 2.0 requires that VirtualBox allow nested virtualization. I later fixed this and tested 2.0 as well.
2. WSL does not launch systemd as the first process (PID 1). This means that it will take some more work to get, for example, Gnome to work. Most of the solutions to this problem require WSL 2.0.
Here’s the final result: Fedora 33 on WSL on a Windows 10 VM on a Fedora 31 host!
Check the troubleshooting section past the references for suggestions on how to fix common errors.
1. Installing the Windows Subsystem for Linux
Assuming a Windows 10 installation (either virtual or native) is available, the first step in this process is to install WSL. Microsoft’s installation guide for WSL is pretty comprehensive, . Open Powershell as an administrator and execute:
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
For WSL 2.0 support, VirtualBox must have nested virtualization enabled so that the Windows 10 virtual machine can use Hyper-V Paravirtualization and VT-x/AMD-V. If those are enabled, execute the following
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
> wsl --set-default-version 2
Note that WSL 2.0 is not required. This example will work fine with WSL 1.0, which is how I initially tried all of this before figuring out my error.
It is also possible to enable these features by searching for “Windows Feature” and using the GUI.
Once the features are enabled, you’re good to go although a restart wouldn’t hurt since this is Windows.
2. Loading the Fedora Container Image
The simplest way to load Fedora into WSL is to follow Jonathan Bowman’s example, . Download the Fedora Container Base, which is a minimal (34MB) container-sized flavor of Fedora built for use with Docker, . As suggested in Bowman’s article, I also installed 7-Zip to open the Fedora tarball and I extracted the contents to my home directory. I also created the recommended $HOME\wsl\fedora directory. Once that was complete, I imported the Fedora rootfs filesystem (renamed to fedora33-20200828.tar from layer.tar) into WSL with
> wsl --import fedora $HOME\wsl\fedora $HOME\wsl\fedora33-20200828.tar
Fedora should now appear in the list of Linux flavors available:
> wsl -l
Open a Fedora shell by running
> wsl -d fedora
3. Bootstrapping into LXDE
Having a Fedora shell running is great, but what about all that other Linux awesomeness, like a desktop environment? Getting more complicated desktops like Gnome running takes some effort, but getting LXDE running is pretty simple.
First, download and install a native Windows X server that Fedora can use for it’s display. I used the VcXsrv Windows X Server, . Once the X server is installed, be sure to start it from the Start Menu. Back in the Fedora shell running inside Powershell, install the xclock and hostname packages with this command
$ dnf install xclock hostname
Next, use hostname to verify your ip address
$ hostname -i
in order to export the display port correctly. In my case, the IP address was 127.0.0.1. You should set the opengl settings for the X server as well:
$ export DISPLAY="127.0.0.1:0"
$ export LIBGL_ALWAYS_INDIRECT=1
Test that the X server is running properly by executing xclock
If that works, install and execute LXDE:
$ dnf group install "LXDE Desktop"
If everything works out ok, LXDE should load in your X window.
4. Bonus round: GCC
As a bonus, getting GCC 10 on Windows is now really simple using the Fedora package manager, dnf. This was my main motivation for trying this out since up-to-date compilers are basic necessities in my line of work. Getting ready for hello world is pretty easy:
$ dnf install gcc vim
I didn’t test this with Emacs because I wanted to make sure I used a real editor to write “Hello World!” in C. 😉
5. Bonus round: Eclipse
Since I’ve been known to use Eclipse, I decided to try it out. The following commands will get it going, but note that it requires a separate user account because Eclipse will not run as root.
$ dnf group install "Fedora Eclipse"
$ useradd test
$ su test
I’m rather impressed with WSL and the relative ease of configuring it for Fedora. I would like to share a few thoughts on the performance of this versus normal virtualization.
My impression is that this option is rather performant when compared to a full virtual machine, and possibly even more so with a native Windows installation that can run WSL 2.0. I suspect that is mostly due to
1. the use of a native X server instead of a virtual display, and
2. being naturally lightweight by design.
I think it is also important to point out that the WSL Fedora installation actually responds faster than the Windows 10 VM. This is likely because of antivirus software or security layers. I’ve seen the same thing happen when playing World of Warcraft and other games with Wine. They are faster on Wine on Linux because all of those “extra features” that Windows puts in the way are not there. Something similar may be happening here.
The performance of GCC and Eclipse were really quite usable, but indeed a little slow. They were faster than running natively on my Raspberry Pi, so I suspect the slowness is only because of being buried in so many layers of virtualization.
There are a few things that I need to investigate further:
1. Systemd and Gnome support.
2. Multiuser mode – this example is all with the root user.
3. Connecting Visual Studio Code on Windows 10 to Fedora 33 through WSL (thanks to Mark Martin for the tip).
 – Microsoft, Windows Subsystem for Linux Installation Guide for Windows 10
 – Jonathan Bowman, Install Fedora 33 or 32 on Windows Subsystem for Linux (WSL)
 – Fedora Container Base
 – VcXsrv
There are a number of small errors that might pop up. Here are a few and suggestions on how to fix them.
‘–set-default-version’ not available
Error messages about ‘–set-default-version’ not being available in wsl indicate that the system has not been updated to the latest version of Windows and the WSL installation is 1.0. Check for updates to resolve this issue.
This error, which is commonly encountered when setting the default WSL version to 2.0, indicates that the WSL kernel needs to be updated. Update the WSL Linux Kernel.