Red Hat Insights image builder enables you to create an image suitable for Windows Subsystem Linux (WSL) so that you can run a Linux environment directly on your Windows machine. You can find the required prerequisites by accessing Install WSL: Prerequisites. You can use most of the command-line tools, utilities, and applications. The kernel is supplied by Microsoft, and developed on WSL2-Linux-Kernel.
Note: This feature is supported for the Red Hat Enterprise Linux (RHEL) 8 and 9 versions, and it is available only in the Preview mode.
Workflow
The workflow can be summarized as follows:
- Using Insights image builder on the Preview mode, create a customized WSL - Windows Subsystem for Linux (
.tar.gz
) image. - Download the
.tar.gz
image to your Windows machine. - Import the
.tar.gz
container image to the Windows machine. The image you will build does not have a kernel system. It is a container that containssystemd
. - After you import the image to WSL and start the container, the image will run as a virtual machine (VM) because it contains a full kernel with full access to hardware.
WSL acts as a hybrid VM, whose content is supplied by Red Hat, but the kernel is supplied by Microsoft Windows.
To create an image suitable for Windows Subsystem Linux, ensure that you have met the following prerequisites and then follow the procedure.
Prerequisites
- You have a running Windows 10 version 2004 and higher or Windows 11 to run the commands in the procedure.
Procedure
Access image builder on the Hybrid Cloud Console (Figure 1).
- On the upper right menu, enable the Preview mode.
- Click Red Hat Insights > RHEL > Inventory > Images. The Insights image builder dashboard will appear.
- Click Create image to open the Create image dialog wizard.
- On the Image output page, select the following:
- From the Release list, select Red Hat Enterprise Linux (RHEL) 8.
- From the Select target environments option, select WSL - Windows Subsystem for Linux (
.tar.gz
). - Click Next.
- On the Register page, select Automatically register and enable advanced capabilities.
- From the dropdown menu, choose an activation key to use for the image. See Creating an activation key.
- Click Next.
- On the File system configuration page, select Recommended: Use automatic partitioning.
- Click Next.
- Optional: On the Content page, complete the following steps to add additional packages to your image:
- On the Additional Red Hat packages step:
- On the Available packages search field, enter the package name and click the → button.
- Click the >> button to add all packages shown in the package search results to the Chosen packages dual list box. Optionally, you can click the > button to add only one selected package at a time.
- On the Custom repositories page, select from the linked custom repositories. Click Next.
- On the Additional custom packages, search for the available packages and add them. Click Next.
- On the Additional Red Hat packages step:
- Optional: On the Name image page, enter a name for the image. Each image has a Universally Unique Identifier (UUID). Click Next.
- On the Review page, verify the image details about the image creation and click Create image.
The system verifies the build manifest of the image. After it reaches 100%, the image is added to the build queue. Insights image builder starts to compose a RHEL image for the x86_64 architecture, in the.tar.gz
format. After the image is ready, you can see it in the image builder dashboard. - On the Instance column, click Download (tar.gz) to save the image to your Windows system host.
Install and run the Linux distribution in WSL
- On your Windows machine, open the terminal command-line prompt.
To show the Windows subsystem for Linux distributions currently installed on your Windows machine, enter:
$ wsl -l C:\Users\username>wsl -1 Windows Subsystem for Linux Distributions: r8fs r8def r8sub r8subpre C:\Users\<username>
To list the official images, enter the following command. You can see a list of valid distributions that can be installed.
$ wsl -l -o
NAME FRIENDLY NAME Ubuntu Ubuntu Debian Debian GNU/Linux Kali-linux Kali Linux Rolling Ubuntu-18.04 Ubuntu 18.04 LTS Ubuntu-20.04 Ubuntu 20.04 LTS Ubuntu-22.04 Ubuntu 22.04 LTS OracleLinux_7_9 Oracle Linux 7.9 OracleLinux_8_7 Oracle Linux 8.7 OracleLinux_9_1 Oracle Linux 9.1 openSUSE-Leap-15.5 openSUSE Leap-15.5 SUSE-Linux-Enterprise-Server-15-SP4 SUSE Linux Enterprise Server 15 SP4 SUSE-Linux-Enterprise-Server-15-SP5 SUSE Linux Enterprise Server 15 SP5 openSUSE-Tumbleweed openSUSE Tumbleweed
Import the Linux distribution that you created to WSL by using the following command:
$ wsl -–import <DistributionName> <InstallLocation> <FileName>
For example:
$ wsl --import rhel8wsl D:\WLS\rhel8wsl \Download\imagebuilder\composer-api-sub-disk.tar.gz
rhel8wsl
is the name of the distribution.D:\WLS\rhel8wsl
is the location where the filesystem will be located.Download\imagebuilder\composer-api-sub-disk.tar.gz
is the .
After the command finishes running, it imports the image. Once importing the image completes successfully, run the command to check the distributions available for you.
Run the following command to show the Windows subsystem for Linux distributions currently installed on your Windows machine again. You will be prompted with your imported image listed between the existing images:
$ wsl -l
Launch the image, specifying the distribution name:
$ wsl -d <name of the distro>
The name of the distro in this case is
rhel8
.
Verification
After the image launches in the VM, you can perform the following verification.
To set up a password for root, enter:
# passwd
You will be prompted to type a new password and retype the same password for confirmation.
Check the system subscriptions:
# systemctl status osbuild-first-boot.service
Check the subscription manager status:
# subscription-manager status
You can install packages, for example:
# dnf install -y cockpit
Additional resources
- Windows Subsystem for Linux Documentation
- Exercise - Install and set up Linux on Windows with WSL
- How to install Linux on Windows with WSL
Important: This document is provided as a Service Preview and only includes or highlights features that are new as part of the public Service Preview. It is under development and is subject to substantial change. Consider the included information incomplete and use it with caution, as a Service Preview feature is not intended for production use at this point. For more information on Service Previews, see Red Hat Hybrid Cloud Console Life Cycle.
Last updated: June 24, 2024