If you’re like me, you may find yourself running Windows for a variety of reasons from work to gaming. Sure you could run Fedora in a virtual machine or as a container, but those don’t blend into a common windows experience as easily as the Windows Subsystem for Linux (WSL). Using Fedora via WSL will let you blend the two environments together for a fantastic development environment.
There are a few basics you’ll need in order to make this all work. You should be running Windows 10, and have WSL2 installed already. If not, check out the Microsoft documentation for instructions, and come back here when you’re finished. Microsoft recommends setting wsl2 as the distro default for simplicity. This guide assumes you’ve done that.
Next, you’re going to need some means of unpacking xz compressed files. You can do this with another WSL-based distribution, or use 7zip.
Download a Fedora 33 rootfs
Since Fedora doesn’t ship an actual rootfs archive, we’re going to abuse the one used to generate the container image for dockerhub. You will want to download the tar.xz file from the fedora-cloud GitHub repository. Once you have the tar.xz, uncompress it, but don’t unpack it. You want to end up with something like fedora-33-datestamp.tar. Once you have that, you’re ready to build the image.
Composing the WSL Fedora build
I prefer to use c:\distros, but you can choose nearly whatever location you want. Whatever you choose, make sure the top level path exists before you import the build. Now open a cmd or powershell prompt, because it’s time to import:
wsl.exe --import Fedora-33 c:\distros\Fedora-33 $HOME\Downloads\fedora-33.tar
You will see Fedora-33 show up in wsl’s list
PS C:\Users\jperrin> wsl.exe -l -v
NAME STATE VERSION
Fedora-33 Stopped 2
From here, you can start to play around with Fedora in wsl, but we have a few things we need to do to make it actually useful as a wsl distro.
wsl -d Fedora-33
This will launch Fedora’s wsl instance as the root user. From here, you’re going to install a few core packages and set a new default user. You’re also going to need to configure sudo, otherwise you won’t be able to easily elevate privileges if you need to install something else later.
dnf install wget curl sudo ncurses dnf-plugins-core dnf-utils passwd findutils
wslutilites uses curl and wget for things like VS Code integration, so they’re useful to have around. Since you need to use a Copr repo for this, you want the added dnf functionality.
Add your user
Now it’s time to add your user, and set it as the default.
useradd -G wheel yourusername
Now that you’ve created your username and added a password, make sure they work. Exit the wsl instance, and launch it again, this time specifying the username. You’re also going to test sudo, and check your uid.
wsl -d Fedora-33 -u yourusername
$ sudo cat /etc/shadow
Assuming everything worked fine, you’re now ready to set the default user for your Fedora setup in Windows. To do this, exit the wsl instance and get back into Powershell. This Powershell one-liner configures your user properly:
Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName | Where-Object -Property DistributionName -eq Fedora-33 | Set-ItemProperty -Name DefaultUid -Value 1000
Now you should be able to launch WSL again without specifying a user, and be yourself instead of root.
From here, you’re done getting the basic Fedora 33 setup running in wsl, but it doesn’t have the Windows integration piece yet. If this is something you want, there’s a Copr repo to enable. If you choose to add this piece, you’ll be able to run Windows apps directly from inside your shell, as well as integrate your Linux environment easily with VS Code. Note that Copr is not officially supported by Fedora infrastructure. Use packages at your own risk
dnf copr enable trustywolf/wslu
Now you can go configure your terminal, setup a Python development environment, or however else you want to use Fedora 33. Enjoy!
Unfortunately, no one has yet created the official Fedora’s app for Microsoft Store.
Actually, someone did create it; it’s just that actually getting something into the app store requires acceptance of legal terms Fedora can’t agree to. We’re still working on finding alternate solutions.
Now the details on those issues and what work-arounds are considered would be an interesting article for the Magazine!
And if you create an Appx file that users can install by double clicking on it, is there still the isse of legal Terms ?
I just activated WSL, went to the Microsoft Store and downloaded the app. It’s working. I was actually surprised while reading the article that there was so much work involved.
(I’m writing from a proper 100% Fedora 33 Dell laptop, BTW)
Mhm, while the article is hopefully helpful for people out there, I’m disappointed to see content marketing for Microsoft Windows on Fedora Magazine. But hey, we live in strange times.
I go along this.
MS and Apple alike have made it difficult to dual boot, and it is no accident.
It did not take long for github after being acquired by MS to exhibit Linux issues…
Consequently Fedora Magazine, should restrain to advertise MS products, Apple too.
But documenting new attempts to preempt hardware platforms so Linux cannot be run there, should be documented, ideally with workarounds.
I agree fully.
“It did not take long for github after being acquired by MS to exhibit Linux issues…”
Can you please explain what you mean by this?
Would it not be a bit easier to install the “Fedora Remix for WSL” product from the Windows store?
Yeah, it costs $20 USD
I was still hoping Fedora one day appears in official Microsoft store (same as Ubuntu, SUSE, Debian, …) special when RedHat(IBM) is partner with Microsoft in Azure. This is kind of sad, but thanks for the guide.
Thank you for your easy to understand article. So everybody has the choice when and where he/she wants to use the different OS’s. This links different “fascinating worlds” seamlessly.
It is not going to appear anytime soon – the reason why it is not there is legal. Microsoft wants indemnification agreement and the Fedora legal obviously declined.
For more info, see here: https://email@example.com/thread/JA4FEGORE53RXKOPRADODTBUCQN3XVJE/
Isn’t WSL essentially a Microsoft distro of Linux?
Isn’t this an appeal to the hoi polli of users?
No, WSL is a system whereby packages from a Linux distribution are run in a container-like environment on Windows. It uses a Microsoft-provided version of the standard Linux kernel.
These instructions are for WSL2, which means Fedora is running in a Hyper-V VM, so not the container-like OS in WSL1.
Excellent guide, thanks! Got this up and running in minutes and learned a bit more about how WSL works in the process (compared to just pulling in an app).
Tensorflow and pytorch GPU setup for Machine learning is difficult in Fedora,so we are forced to take up debian packages like ubuntu.
When changing the password, I received the following error:
/usr/share/cracklib/pw_dict.pwd.gz: No such file or directory
BAD PASSWORD: The password fails the dictionary check – error loading dictionary
Retype new password:
passwd: all authentication tokens updated successfully.
solved the problem
There is a slightly easier way to set the default user, create a file called /etc/wsl.conf and set the user there:
WSL reads that file on start, there are other options that can be set such as mounts, check the official Microsoft doco for options.
If only this guide had been written earlier, this is so much better and easier than if you where to try to do it following Microsoft’s instructions, I was attempting it with CentOS, and like Fedora, the LiveISO has no rootfs, so my distro failed, didn’t even think of looking at the Docker image.
Thanks for this, this makes it so much saner and easy.
Ok, can we do vice versa?
I think we can copy windows core, or at least remove Windows bloatware(cortana, edge, etc). Then use KVM to run and expose the necessary apps only. For example steam.
We can do hardware (VGA or LAN) passthrough using kvm.
People use different operating systems the way they need it, this is called freedom of choice. The Edge is not bloatware, but essentially just another Chromium based browser, by the way, available not only for Windows, but also for Linux – please don’t use hate speech.
I’ve created a PowerShell script to create the WSL distribution automatically, it only requires that xz be available on the system path.
Still need to write actual documentation but I’m getting there.
Will wait until there is a LSW Linux Subsystem for Windows
Donald Sebastian Leung
That’s just Wine, no?
WINE or the Codeweaver’s version called Crossover
Did you miss out what to install from the copr?
dnf install wslu
yeah. I thought I had that in there, but you’re right. I missed it. Thanks for adding the comment here for folks to find.
You know that for the customize part there is an official one by
That one (at the time of writing this anyway) doesn’t support f33 yet.
Silesh K Nair
Jonathan D Bowman
Nice write-up. Very thoughtful to include wslu. Thanks!
hola y para cuando tendremos un sistema windows en fedora ,así como si fuera una aplicación como cualquier otra, hasta cuando gnu/linux sera usado como aplicación de una tienda, a caso no se quieren ustedes mismos? que pretende microsoft con estas jugadas? traer mas gente a su sistema las personas pueden decir, “bueno aqui lo tengo todo para voy a instalar linux”, si esto sigue así cada vez habrá menos personas que puedan usarlo, y los fabricantes de hardware podrán decir “para que hago driver de hardware que nadie usa” por eso es importante tomar buenas deciciones para que no afecten el futuro de Fedora y de todo gnu/linux en general.
Is there a way to create a shortcut, somo sort of launcher to avoid Opening Powershell and launching wsl?
Jonathan D Bowman
Have you tried Windows Terminal? https://github.com/microsoft/terminal
Does this work for Windows Arm laptops as well?
Is there a way to find the image by navigating the Fedora GitHub account? Just to make this article more future proof.
For example when Fedora 34 comes out we need a sane way of finding its rootfs image.
I’ll remain out of the legal debate and only frown at MS content on Fedora Magazine!!! My instinct is that the WSL is important to MS customers.
One note: To get preview 20262 I needed to change my insider ring to
dev from beta. Everything was smooth sailing after that!
Thanks for a good article!