CentOS Linux Version 8 On Windows Subsystem for Linux

We will look at setting up CentOS version 8 on Windows Subsystem for Linux (WSL). Due to certain issues with the Microsoft Store licensing there is not an officially supported and free version of CentOS available the way Ubuntu Linux is. We will outline how to build a WSL compatible image, and then deploy and configure it. With only very minor changes, these instructions would also work with RedHat Enterprise Linux 8, and Fedora Linux.

 

Microsoft’s Windows Subsystem for Linux (WSL) is the latest in a long line of Windows and Unix/Linux integration products that goes back decades. WSL and WSL 2 differ with all prior attempts in two specific ways. There is a very high level of integration with the hosting Windows environment AND it still provides binary compatibility with the running Linux environment. There have been many integration products prior to WSL that had the integration, but none had binary compatibility with x86 Linux. All virtualization environments provide binary compatibility, but at the expense of tight integration.

 

Windows Subsystem for Linux version 1 isn’t true virtualization, and doesn’t have the Linux kernel running. The two major drawbacks to this approach are a lack of full Linux systems calls, and the file system has noticeable performance bottlenecks. Windows Subsystem for Linux version 2 addresses these two issues by providing a full virtualization environment underneath to support running the Linux kernel. We will be looking at WSL 2, however, there are only a couple of differences in the instructions, so either version would work.

 

CentOS 8 root filesystem image

The first part is to create the CentOS 8 filesystem image. Unfortunately, this requires root/sudo access to an already running CentOS/Fedora/RHEL system with dnf installed. This can be a virtualized guest running on any virtualization platform, or in a cloud service. We are going to assume the reader has access to such a system, and is logged in as a user with sudo rights.

 

In your CentOS/RHEL 8, or Fedora system run the following to build the root filesystem:

 

CentOS Linux Version 8 On Windows Subsystem for Linux_3

 

At this point transfer the file CentOS-8-rootfs.tar to the Windows WSL host, you can use a program like WinSCP or FileZilla for this.

 

Install Windows Subsystem for Linux

On the Windows host, WSL must be installed and setup. Open an elevated PowerShell and run:

CentOS Linux Version 8 On Windows Subsystem for Linux_4

 

This will install WSL version 1. If you don’t have Windows 10 version 2004 or newer, or you don’t have virtualization support, you can jump to Setting Up CentOS 8, otherwise continue on to configure WSL 2. (We recommend WSL 2)

While still in the elevated PowerShell run:

CentOS Linux Version 8 On Windows Subsystem for Linux_5

 

Now download and run (double click on the MSI) the WSL 2 Linux kernel update package for x86_64 computers from Microsoft at:

WSL2 Linux kernel update package for x64 machines (windows.net)

To make WSL 2 the default version, which we recommend, run the following in an elevated PowerShell:

CentOS Linux Version 8 On Windows Subsystem for Linux_6

 

Now restart the Windows system, if the elevated PowerShell is open, and the system is ready for restart run:

CentOS Linux Version 8 On Windows Subsystem for Linux_7

 

Setting up CentOS 8

Now the WSL is setup and installed on the Windows system, CentOS 8 needs to be added as a Linux distribution. Open a PowerShell (doesn’t need to be elevated at this point):

CentOS Linux Version 8 On Windows Subsystem for Linux_8

 

Your PowerShell should look similar to the above. Now that we have CentOS loaded into WSL, we can go in and make it work well. After logging back in, open a PowerShell, and type in:

CentOS Linux Version 8 On Windows Subsystem for Linux_9

 

The last three lines above should be typed in as one long line. Now WSL is setup with CentOS!

Windows Terminal

The new Windows Terminal also works well with WSL and we recommend using it. To install Terminal, open the Microsoft Store application and search for Terminal. It should look like this:

 

CentOS Linux Version 8 On Windows Subsystem for Linux_10

Click the Install button and after it is installed run it. When it is initially run, it will open a PowerShell by default, but it will find the CentOS distribution, and that can be launched with the down arrow on the menu bar.

CentOS Linux Version 8 On Windows Subsystem for Linux_11

 

Open the CentOS tab, and you should be in Linux!

The Windows Terminal allows for many settings. Some customizations we recommend for Terminal are listed below, and this can at least be a start, that can then be changed to what works for you. On the Down select the Settings gear:

In the “schemes” section replace it with:

CentOS Linux Version 8 On Windows Subsystem for Linux_12

Then to use schemes in the profiles:

CentOS Linux Version 8 On Windows Subsystem for Linux_13

 

X Windows

It is also possible to use X Windows (the GUI for Linux) with WSL, but nothing is included. There are a number of free and commercial choices available. Once you have an X server setup on Windows, you can configure CentOS to use by adding the following lines to the .bashrc file.

 CentOS Linux Version 8 On Windows Subsystem for Linux_14

 

If you would like to discuss this more, feel free to contact us

 

Subscribe Here For Our Blogs:

Recent Posts