Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - Using Fedora 33 with Microsoft’s WSL2

#1
Using Fedora 33 with Microsoft’s WSL2

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.

Prerequisites


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 update
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
passwd 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
$id -u
1000
$ 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.

Customize!


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!



https://www.sickgaming.net/blog/2020/11/...ofts-wsl2/
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Fedora - Getting started with Fedora CoreOS xSicKxBot 0 4 8 hours ago
Last Post: xSicKxBot
  Fedora - Podman with capabilities on Fedora xSicKxBot 0 14 11-17-2020, 02:07 AM
Last Post: xSicKxBot
  Fedora - 4 cool new projects to try in COPR from October 2020 xSicKxBot 1 61 11-10-2020, 06:23 AM
Last Post: JohnSharp
  Fedora - Getting started with Stratis encryption xSicKxBot 0 23 11-09-2020, 11:05 PM
Last Post: xSicKxBot
  Fedora - Reclaim hard-drive space with LVM xSicKxBot 0 28 11-07-2020, 01:28 AM
Last Post: xSicKxBot
  Fedora - How to rebase to Fedora 33 on Silverblue xSicKxBot 0 35 10-31-2020, 12:26 AM
Last Post: xSicKxBot
  Fedora - What’s new in Fedora 33 Workstation xSicKxBot 0 32 10-28-2020, 11:24 PM
Last Post: xSicKxBot
  Fedora - Fedora 33 is officially here! xSicKxBot 0 34 10-27-2020, 09:34 PM
Last Post: xSicKxBot
  Fedora - Contribute at the Fedora Test Week for Kernel 5.9 xSicKxBot 0 40 10-25-2020, 12:22 AM
Last Post: xSicKxBot
  Fedora - Secure NTP with NTS xSicKxBot 0 40 10-23-2020, 09:59 PM
Last Post: xSicKxBot

Forum Jump:

Become a Patron!
[-]
Upcoming Events

[-]
Latest Threads
[Tut] Exponential Fit with SciPy’s curve...
Last Post: xSicKxBot
Today 05:44 AM
» Replies: 0
» Views: 1
(Indie Deal) F1® 2020 (58%) & METAL GEAR...
Last Post: xSicKxBot
Today 05:43 AM
» Replies: 0
» Views: 2
News - Guide: Where To Buy Game & Watch:...
Last Post: xSicKxBot
Today 05:43 AM
» Replies: 0
» Views: 3
News - Sega Genesis Mini Gets Black Frid...
Last Post: xSicKxBot
Today 05:43 AM
» Replies: 0
» Views: 3
Black Friday For Game Developers 2020
Last Post: xSicKxBot
Yesterday 11:41 PM
» Replies: 0
» Views: 3
Fedora - Getting started with Fedora Cor...
Last Post: xSicKxBot
Yesterday 11:41 PM
» Replies: 0
» Views: 4
News - PQube Is Releasing A Totally Free...
Last Post: xSicKxBot
Yesterday 11:41 PM
» Replies: 0
» Views: 4
News - Fortnite Recreates 100 Thieves Ca...
Last Post: xSicKxBot
Yesterday 11:41 PM
» Replies: 0
» Views: 4
News - Pokémon Teases ‘Very Special’ 25t...
Last Post: xSicKxBot
Yesterday 05:15 PM
» Replies: 0
» Views: 3
Xbox Wire - 7 Tips to Help You Run Your ...
Last Post: xSicKxBot
Yesterday 05:15 PM
» Replies: 0
» Views: 3

[-]
Twitter

[-]
Sponsored
Get the Deal of the Week at RefurBees.com

Copyright © SickGaming.net 2012-2020