Howto : RHEL 8.2 running under WSL2

Latest response

I want to get an instance of RHEL 8.2 running under WSL2 and register that with my developer account.

Questions: (If you have actually done this)

  1. What would I download? Where would I get it?
  2. What would I need to do to get this up and running?

I am looking for some minimal layout to run a shell only under MS WSL2


Red Hat is missing out on the last mile of reaching developers by not offering this in the Microsoft store.

Ubuntu is there, SUSE is there, Debian is there, many others are there.

Red Hat does a lot for developer engagement, except for the last mile things.

I would very much like to help here.

Responses

Hi !

Who is the owner of the store ? Microsoft - right ? So, I think best would be to ask Microsoft ... :)
You can't blame Red Hat for this "last mile thing", especially not for WSL - a unique MS solution.

Regards,
Christian

That's just wrong... It's like blaming Google that RH does not have an "Subscription Management" app in the Google Play Store. Literally anyone can publish software on the Microsoft Store and yes spoiler alert, even it that would have been the case RH could just publish the resources for installing it from cli. Example: https://github.com/WhitewaterFoundry/Fedora-Remix-for-WSL

Yes I'm blaming RH for it not Microsoft, like anyone should. RH is failing in the "last mile thing" not Microsoft.

Hi Thomas,

Of course I respect your opinion ... but possibly it is a contracting issue between MS and Red Hat ? :)

Regards,
Christian

More like a RH issue if you ask me. There is no licensing involved to create a WSL distro, however since RH requires a subscription I doubt they are willing to deal with the plethora of users installing a RH WSL from the Windows store only to find out its useless until they create at the very least a developer account on redhat.com to get the necessary subscriptions to use it. Those users are not the target audience for RH.

However, they could provide resources here to help people DIY, like they do with other not quite standard uses of RH in the knowledgebase. Like migrating CentOS/Oracle to RHEL or setting up LXD on RHEL.

All, I just wanted to chime in as one of the product managers investigating RHEL on WSL2. It's something we're definitely taking a look at. We're still evaluating the process of putting Red Hat content in the Microsoft Store and also how to document ways for people to import images.

I'd like to try and focus the conversation on "why" a user would want this as that's extremely useful as a PM. I always want to understand the "job to be done" - any information you all could provide around that would be very helpful.

Scott., RHEL is our corporate distro. It's the only supported one. If it's Linux, it's RHEL. So, for RPM/satellite server support, especially when we're limited to on-prem, potentially offline for gov't contract reasons, it has to be RHEL not another distro.

Many developers use Windows due to it's easy of use, corporate productivity (e.g. Office), or (arguably) superior dev tools in Visual Studio. Many of our SW products are cross-platform too, so Windows & Linux. Therefore, for many, the ideal use case is develop on VS and target both Win & Linux w/ cmake. VS has come a long way, and can now accel at remote Linux debugging vs others like Eclipse CDT.

The ability to use WSL2 now enables use to develop Win and Linux targeting RHEL on the same workstation w/o a different VM (eg. VMware Workstation) or different physical. Previous limitation of CUDA development are now even possible on WSL2.
So, now WSL2 + Windows can become a one-stop-shop for primary cross-platform development.

I'm not on the same company as Ryan. But everything he said is the same on my Company.

Nothing to add, it's point on on the issue here: Windows Laptops/Desktop is the norm. Devs "hate" Windows and wants to do stuff on Linux, hence the WSL. So now, they are doing it with Ubuntu (eeks) and want to replicate that in the production. But we only authorize RHEL.

On top of all that, having an official RHEL WSL would help us "control" what happens on the WSL2 stack (read: verify all packages are properly applied). Something that is absolutely not possible with Ubuntu (or anything else).

Scott, we are a big ISV targeting RHEL for our solutions. Our main if not unique development platform is Windows and as the person in charge of OS and compiler certifications for Linux I'm trying to convince everyone to switch to Linux especially for cloud products development. But recently I heard from Red Hat that downstream Eclipse CDT (RHEL 8 module) would not be realistic to maintain so that's why it is not shipped with RHEL 8. I was advised to use QTCreator from EPEL instead. IDE being the favorite tool for Windows developers, you need a supported IDE on Linux for them to switch. Also Visual Studio for Linux will not come for obvious reasons while being the #1 feature request from the Visual Studio community. We are seeing growing number of requests to support Hyper-V based solutions (Docker for Windows or WSL2) and can't offer a decent alternatives with a supported C++ IDE on Linux.

Scott, earlier this year Red Had announced two RHEL programs: the "no-cost RHEL for small production workloads" and the "no-cost RHEL for customer development teams". This is great for a lot of smaller teams because we can switch our development infrastructure from Ubuntu to RHEL. However, the missing piece is support for WSL2 because some developers have Windows machines and we would like to be able to develop software on the same Linux distribution as we have in production.

A possible work-around is to use Hyper-V, which is what I am doing right now, but there are a lot of things to set up and not every developer is willing to spend several hours to forward ports, setup X forwarding and so on, while all these things work out of the box using WSL2.

Right now the company I work for is using Ubuntu, however Red Hat has made some very interesting moves with the two programs I mentioned above and we'd be very happy to migrate to RHEL in the near future.

Hi Scott Our it system engineers need to support both worlds, windows and Linux (rhel) (yes every engineer has its focus but all of them need to know the basics of both worlds). Due to the application landscape and internal policy, all end-users, including the whole it department get windows based clients. So to get, let's say the best of both worlds, we're using WSL (currently fedora) on our devices. To streamline everything it would be so nice to have a rhel based WSL as well, because our whole backend runs on Windows Server, RHEL or OpenShift.

Everything Windows related is done over RDP / RSAT. Everything related to RHEL / OpenShift is done over WSL in combination with the Visual Studio Code integration.

Hope that helps a little :)

I haven't done this with a RHEL directly yet, but this is reasonably easy to do with CentOS. Here are the rough steps I documented for that to help another user: https://lists.centos.org/pipermail/centos/2020-August/351392.html

Yet another related post in the CentOS forum: https://forums.centos.org/viewtopic.php?t=75373.

Old thread, but maybe it helps someone looking for answers on the same question. Easiest way:

1) Install RHEL in a Virtual Machine. Doesn't matter which. I used the boot iso as it is small, and you want to keep the install as minimal as possible to save time. You can always add any package later using dnf

2) When installed, reboot into RHEL and login as root.

3) Create a tarball of the file system:

cd /

tar cvfzp rhel8.tar.gz bin dev etc home lib lib64 media opt run root sbin srv usr var

Note: these are not all directories under / and are intentionally excluded

4) transfer the file rhel8.tar.gz to host system; for easy, I use scp to copy to my server so I can grab it from any workstation

5) Create the WSL instance by importing: wsl.exe --import RHEL rhel8.tar.gz --version 2

6) create a shortcut to wsl -d rhel to start, or start manually.

After first start (it will start with user root) you can go to HKLU\Software\Microsoft\Windows\CurrentVersion\Lxss and change the defaultuid for your distro to whatever you want; typically this would be 1000 for the first user created.

Enjoy your new RHEL8 under WSL2 and install whatever software you need.

See: https://www.sport-touring.eu/old/stuff/rhel83-2.png

Thank you for providing the community these instructions!

Hey, I'm a current RHEL customer (and have been through various sysadmin positions) that needs to do Ansible development work. I need to run through the Ansible tutorials on my personal computer, and I typically run Docker in WSL2, so I can't do the whole Virtualbox thing. I have been looking for a RHEL wsl2 for doing the Ansible Tower training installation. May I request RHEL in WSL2 as a company-released feature request? As you guys recently purchased a Kub security company, I can imagine that this feature would appeal to other customers in enterprise-security-grade settings, who also use Docker.

I did see a few different creative solutions on the internet, but as a current customer, I was wondering if there could ever be a blessed/licensed way to do this?

Sondra, thank you for your response. We're definitely taking a hard look at how/when/if we can add this to the roadmap. I definitely understand why this would be useful to you! Just wanted to let you know that a product manager has seen this and is looking at it!

Hi Sondra, my method as described above is licensed. It doesn't appear RH is interested in doing this and even if they are, it would take time. If you have a need now, you will need to get creative like I was. Not that this is a bad thing, as it taught me a lot about the workings of Wsl.

Take a look at this article--> https://wsl.dev/mobyrhel8/ I have tried most of this out and it works.

this method didn't work for me, when adding the distro manager the wsl hangs after installing the systemd script, maybe there is an updated method to do that, used the way described above by Gijs van Dijk at the end.

just to share it is simple to create from working running RHEL8 in vm, just create tarbole. go to / then

tar cvfzP rhel8.tar.gz bin dev etc home lib lib64 media opt run root sbin srv tmp usr var

as for my experience, this folders are necessary to run the RHEL8 in wsl. if you try to add other directory like etc, the chances of getting error while you import into wsl 2 is very high. So i would stick to those mentioned directory ONLY.

after you have created the tar.gz, copy it to your windows local drive, the execute the wsl import command

wsl --import C:\ --version 2.

example wsl --import centos7 C:\centos7wsl centos7.genie-1.27.tar.gz --version 2

wsl -l ---> it will list the linux distro you have installed wsl -d to run.

viola, you have your RHEL8 in your WSL2. well after you have installed the RHEL8 in your WSL, installing app, server/services and making it run is DIFFERENT story.

RHEL8 is relying to the systemctl command or systemd. which WSL/Microsoft intentionally disabled.

if you want to explore more on how to make the systemctl to work in your WSL, i suggest to google arkane genie github which is working on genie app, develop in DotNet (i believe it).

Me, up to this composing this reply, working for nearly 2 weeks now, how to run, re-create, working genie in WSL in customized linux distro into my Windows 10.

Check my reply just 4 posts above yours. :)

The genie reference looks like a interesting addition though. Will have to check that out.

Quick solution:

  • Does a minimal Redhat 8 install:

https://github.com/yosukes-dev/RHWSL.

  • Start setup with the Red Hat registry.

https://wsl.dev/mobyrhel8/

  • Install packages by groups.

https://access.redhat.com/solutions/3756221

Let's just assume for a second that maybe RedHat isn't possible for X, Y, Z reasons here. Maybe it's licensing, maybe it's something else. OK, so that's out. However, what about CentOS and/or Fedora?

Both of these are now owned by RedHat and touted as your platforms for proving things out before they reach RedHat directly. Why aren't you supporting these in WSL? I think the statement about getting the "last mile" stands here. There have already been community contributions to show what needs to be done. All you have to do here is formalize that and put it into the official store.

WSL is even trying to bring GUI support at this point, which sounds like a lot of the use cases people want from WSL. Many organizations, like ours, work in a hybrid environment where Windows is the primary OS; and then there is some form of development and/or support on the Linux side. Being able to run things like full fledged IDE under Linux, without all the overheard of running a VM manager, is appealing to a lot of people. The only roadblock here is that people don't want to have to "do it themselves". For good or bad, a lot of developers don't care how the Linux side of things works, they just want to write code.

Don't get me wrong here, I've built a 20 year career around supporting Linux, and mostly RedHat, and I know there are plenty of people that could care less about WSL. I also know that it's not the primary business target, by a long shot. I'm am saying, there are legit use cases that could only serve to expand the user base; and help support those that contribute to the platform.

https://www.youtube.com/watch?v=r8uUwsEnTU4

I like to think about this tidbit from the Linus in the same context. Love him or hate him, he has some good points and an organization like RedHat could help to fill some of these voids. You own Fedora, and tout it as a "developer" platform. Some of his points about usability apply, and it's why developers have been choosing things like Ubuntu instead. WSL being one of these usability items for people that have to work in a mixed OS environment. If a user can click a button and have working Ubuntu on Windows, then that's what they're going to do.

Scott - Are you still looking for a use case for WSL 2 & RHEL8?

I'm moving from supporting RHEL hosts to supporting OpenShift clusters. I have a windows laptop on my desk. With my jury-rigged WSL2/RHEL installation, I can run the OpenShift cli(s) in a Windows terminal. I can run "oc" and "odo" commands; since I'm using Windows terminal, links in the command output are clickable. So I can jump to the web console for a cluster, or the URL for a web service with a click. My organization has thousands of RH hosts; a license for a desktop is easy to justify.

Thanks for sharing this use case Paul! It's much appreciated, and I think it makes perfect sense to me! I'm still working on WSL2 and I'll add this to the list I'm using to make a business case!

@Scott McCarty, for me personally as an educational use case it makes things easier to have RHEL from my Windows WSL desktop connecting to my RHEL 9 servers on my ESX servers. Having the same languages speak to each other makes working from my workstation to my servers as seamless as possible. I definitely would advocate to allow RHEL through the MS store to easily install on WSL.

Nick, this makes perfect sense to me, and I'm adding it to my list to make a business case for this!

It's almost a year since this discussion started, still no RHEL in WSL. I've installed AlmaLinux 8 instead, it works just great.

My solution, after https://dev.to/bowmanjd/install-fedora-on-windows-subsystem-for-linux-wsl-4b26 is

On a podman/docker capable host:
     1. podman pull registry.access.redhat.com/ubi8
     2. podman run --name ubi8 ubi8
     3. podman export -o ubi8.tar ubi8
Copy ubi8.tar to Windows
     1. wsl import ubi8 $HOME/wsl/ubi8 ubi8.tar
     2. wsl -d ubi8

I was much more successful in using Andrew's solution above then I did with installing a rhel system into a VM and tar-ing the filesystem manually as outlined in the 'best response'. The biggest issue I had with going the VM route is that enabling systemd in WSL resulted in failure of the WSL instance to start. I also had annoying errors about fstab -a failing etc. Using the standard UBI this was not an issue; I was also able to register/subscribe the system without issue. The only problem I encountered is that language packs aren't part of the UBI so 'Locale not set' warnings were persistent. Setting the locale also failed. Once I installed the language pack for my locale (dnf install glibc-langpack-en) I was able to set the locale with localectl.

Taking the accepted answer and putting it into a little bit better format and updating for the current software.

Create a new RHEL tar.gz
  • Log in to running RHEL8 system and create the file system for WSL2 to use.

    cd /
    sudo tar czfp rhel8-fs.tar.gz bin dev etc home lib lib64 media opt run root sbin srv tmp usr var
    
Run RHEL in WSL2
  • Get the rhel8-fs.tar.gz to your windows system.
  • Create the directory to store the VM.

    mkdir ~/RHEL
    
  • Import the rhel instance

    wsl.exe --import rhel ~/RHEL rhel8-fs.tar.gz --version 2
    
  • Start RHEL instance

    wsl.exe -d rhel
    
  • OR Set RHEL as your default instance

    wsl.exe -s rhel
    
  • Start RHEL instance

    wsl.exe
    

Install plain Ubuntu in wsl2 and docker, then just docker run this rhel8/go-toolset afterwards docker export the stuff to a tar file. Finally wsl --import the just created tar file. Like Andrew Gilmore mentioned earlier

This should be the accepted answer, IMO.

Exporting the container to import into WSL was for me quicker, easier and cleaner than building a whole VM to do the same thing. I used the RHEL8 UBI. Once imported into WSL I was able to subscribe it to my developer subscription etc. and everything works as expected, even systemd.

We have a number of developers who use Windows as their "daily laptop" but need access to do linux based software engineering. Providing RHEL with a known baseline as a container could be quite useful for testing integration, installation packages etc. While Fedora is nice to see the future of RHEL, a baseline that is working and consistent is a better fit for 1000s of engineers to jump into and do their work on an enterprise environment.

VDI solutions may provide WSL desktop containers to users, so having an enterprise tested distribution like RHEL would be an enabler, particularly as it relates to the cyber security patching and rapid response that RHEL provides (e.g bringing the latest RHEL container into the VDI image and knowing it's going to be a quality build with back ported patches and not force an update onto the users or in specific environments).

PS: I'm also looking at Podman hosting on windows to enable local machine container development without a docker installation, which would be a natural fit for a RHEL container.

1) the VSCode plugin for Ansible works great with the remote connection plugin, enabling our customer to develop playbooks directly on their daily laptop. https://code.visualstudio.com/docs/remote/remote-overview https://marketplace.visualstudio.com/items?itemName=redhat.ansible

2) Some RHEL clone operating systems are already on the WSL2 Store, the alternative would be running true RHEL (even with a developer group subscription) on their machines instead of easily installing a RHEL clone.

The current situation is quite unacceptable from my point of view. All the workload is on the end user side, and nothing is done on Red Hat side.

As mentionned:

1/ The Ansible Plugin kinda REQUIRES a WSL2 to work properly on Windows.

2/ All distro exists on WSL2, BUT a Red Hat one (we have SUSE, Oracle Linux, and all the debian-based ones). Nothing from Red Hat. All the RH-clones are also under a licence requirement, so it's not a valid argument not to have a RHEL release. All releases of WSL2 are listed here: https://github.com/microsoft/WSL/blob/master/distributions/DistributionInfo.json

3/ Missing the Red Hat makes so the end user will prefer/use by default anything but Red Hat. They won't bother in working to build, deploy, run a Red Hat WSL2 image.

4/ Without a properly built RHEL image, it makes it even more difficult to keep track of its content, and prevents a "clean & neat" usage of WSL2 (read under proper control/management), and just creates shadow IT all the way.

Currently, my colleagues sees Red Hat requirements as a PAIN, not as a facilitator in this scenario. And it clearly puts them in a situation to try and avoid using Red Hat everywhere else! That's exactly the opposite of what we are hoping to get from Red Hat in this situation. Needless to say that the developper subs allows up to 16 instances, so BLOCKING the Red Hat in WSL2 for "legal" purpose seems a false excuse.

Sorry for beeing a bit blunt, but I've to admit I've been waiting for this for about 2+ years now :(

Hi, My two pieces here...

I am a computer specialist in system, network and security graduate in 2006. I got specialised on RHEL, but I use a lot of distributions even tried Unix/BSD(NetBSD, OpenBSD, FreeBSD), Debian, Archlinux, Ubuntu, Fedora, CentOS.... But for professional way, I became Linux RHEL specialist since RHEL4 for a long years like some Guys on this discussion. I am working as Consultant RHEL for the JB company since few years on the satellite mostly. JB is trying to help Red Hat a lot because he wants to have a way to make it clean as Linux usage and the community. Feel strange here, this subjet has no more evolved despite it is not a technical problem... despite the explaination experienced Guys, we are several to think that we don't understand this Red Hat position... it is just weird...

I encourage strongly, at my turn (with my poor english :) ) , Red Hat to make something because it is a easy step to earn big , increase base of users. Windows, i am not a user no more at my home , but me (in the company), as we have it in the most of companies as Desktop computer/Personal Computer contrarily to Red Hat employee that seems to be on Fedora ;)

In the order, to make a really difference, i know that nobody is interested because it is windows and microsoft. But believe me, it is a STRONG none sense, that Red Hat family is not there. It is a terrible mistake ! the cost is certainly very few but the consequence will be certainly terrible for Red Hat. Nor the community nor the Enterprise Grade Red Hat is there in WSL... why ? Will you want the end of Red Hat (even Fedora not there ? what is it happening at Red Hat ? This is unbelievable, how the leader of open source enterprise grade can be not there ? WSL is a store /a shop / an easy advertisement.... why let a highway for the others distrubitions and let it go (no take a chance for Red Hat or at least for Fedora / CentOS) ? This subjet is easy, already work in this discution, why do not use a trainee padawan and a jedi master to follow him/her on that subjet ? Windows is not Linux but this is often the first OS used by the most of commun computer users will be windows, we can't change it and ubuntu even didn't change it, if one day android got a WSL equivalent Red Hat as at least is community branch should be / must be official here !

Please do it something ! it feels very strange position this complete silence on that ? it is a real big mistake in term of market (Windows is everywhere like Android) ! when you are not there, the others take the place ? It is not only for company, it is a terrible for every new users on Windows that could be choose Fedora/CentOS/Red Hat and even more for devlopper or next devloppers/users

Note : I am strongly attached by Red Hat, since begining of my work as computer science for Company. Note 2: another thing could be done a professional OS Android very securly for company, think to that for Red Hat, it could be bring the brandname in every house.

Regards, Aymeric

Red Hat is currently assisting customers who have RHEL subscriptions, either developer or production, with the installation of RHEL on WSL2. We are also working on some new features to make use with WSL2 even easier. If you wish to take advantage of this, please contact your Red Hat account team and ask them for assistance.

thanks, Brian Gollaher, Red Hat Enterprise Linux Product Management

That is a much higher barrier to entry than clicking an MS store link or just typing in "wsl --install rhel-9" would be, like the rest of the WSL community is able to.

I'm not sure what hand holding the account team is going to provide that wouldn't be just as easy as a knowledge base article or even a response here.

Regardless, I stand by my answer above, it's relatively simple to access a ubi8 image via podman, export it, and import into wsl, except that's 4 steps and another computer more than just installing a WSL image would be.

This is a critical choice, and I think RH is losing mindshare every time this isn't immediately available.

Greetings everyone,

If it helps. I came across this article from Microsoft. Allowing you to import any Linux Distro with its tar file. I haven't tried it out yet.

https://learn.microsoft.com/en-us/windows/wsl/use-custom-distro

My use case is to slowly introduce an Enterprise Linux Distro where I work.

Yes, custom distro.

This is what I did as well. Ran a ubi8 container and then exported its filesystem. I've configured it with Ansible as a template and distribute it as our RHEL WSL distro.

I think the way to do it is I would make a vm image, make a tarball file of the system and create that as a wsl2 instance using a terminal to be able to run it on

Find a way to run a container (not a VM) and then export its filesystem. Example here for CentOS: https://learn.microsoft.com/en-us/windows/wsl/use-custom-distro#export-the-tar-from-a-container

We now have an article explaining how to use RHEL with WSL2 here: https://developers.redhat.com/articles/2023/11/15/create-customized-rhel-images-wsl-environment

We encourage everyone to give it a try and let us know your feedback.

It actually works like a charm. The new feature to generate a WSL2 image from within the Image Builder (Cloud version) was the one thing that made all the difference.

One thing worth knowing as well when performing the WSL installation is to check the need to use the --web-download, as the MS Store may not be reachable in a corporate environment. And in this situation and without the --web-download, the WSL version may not be installed properly.

In addition to that, using podman desktop allows to activate a NATing feature for the WSL instance (usermode networking : https://podman-desktop.io/blog/podman-desktop-release-1.3). Effectively, this may be required when using some VPNs (Cisco Anyconnect, i'm looking at you !!) that prevents the WSL instance to do any network activity.

And the cherry on the cake is that the subscription-manager works, and can target a Satellite (but that's another story)

so THANK YOU !!!