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.
Install RHEL
- 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.
Unregister VM
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
subscription-manager unregister
subscription-manager clean
Create Tarball and Transfer to WSL Host
- 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 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\Lxss
and change theDecimal
value ofDefaultUid
for 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 refresh
subscription-manager attach --auto
- You should now be able to get updates using the command below:
dnf upgrade
If you changed the
DefaultUid
above in the registry, and you're not currently logged into the WSL instance asroot
, you'll need to appendsudo
in front of all of the commands above
All Done!
Let me know in the comments if you have any issues not mentioned above!
Enjoy RHEL under WSL2 !