RHEL + Windows 10 with WSL2
This article is going to assume you already have WSL installed, and have restarted the machine to finish that install. If you need to install WSL, please go here first. You also need to ensure you have updated WSL to WSL2, the previous link provided can assist with that as well.
- You'll need to install RHEL in a Virtual Machine (VM). It doesn't matter which hypervisor you use. I used ProxMox / QEMU.
Just to make things easier later, I went ahead and set the root password, and created an Administrator account
- Under Software Selection, I picked Minimal Install to keep things as small as possible.
- Once installed, reboot into RHEL and login as root.
During the Installation, you had to register this machine with Red Hat. To make a clean image (that can be used over an over), it's best to remove the subscription, and unregister the VM.
- Run these commands to fully unregister, and remove all subscriptions:
subscription-manager remove --all
Create Tarball and Transfer to WSL Host
- Create a tarball of the file system:
tar cvfzp rhel8.tar.gz bin dev etc home lib lib64 media opt run root sbin srv tmp usr var
Note: these are not all of the directories under / and the ones not listed are intentionally excluded
- Transfer the file rhel8.tar.gz to your host system.
To make it easy, I used WinSCP to connect to the VM (from the host), and copy the file
Create WSL Instance and Start It
- Create the WSL instance by importing the tarball:
wsl.exe --import RHEL rhel8.tar.gz --version 2
- Create a shortcut to wsl -d rhel to start, or start manually.
OPTIONAL: Change Default user in WSL Instance
- You'll notice it starts as the root user. If you would like to change this, you can go to
HKCU\Software\Microsoft\Windows\CurrentVersion\Lxssand change the
DefaultUidfor your distro to whatever you want. See image below for reference.
- Typically this would be 1000 for the first user created (including the user you created during the setup process).
Re-register with Red Hat
In order to get updates, you'll need to re-register this instance with Red Hat
- You can use these commands to re-register:
subscription-manager register --username <username> --password <secret>
Replace <username> and <secret> with your account information
subscription-manager attach --auto
- You should now be able to get updates using the command below:
If you changed the
DefaultUidabove in the registry, and you're not currently logged into the WSL instance as
root, you'll need to append
sudoin front of all of the commands above
Let me know in the comments if you have any issues not mentioned above!
Enjoy RHEL under WSL2 !