IT Blogs & News - Written by IT Professionals - iuvo Technologies

CentOS Linux Version 8 On Windows Subsystem for Linux

Written by Edwin Perkins | Dec 29, 2020 2:30:00 PM

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 system 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:

 

 

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 set up. Open an elevated PowerShell and run:

 

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:

 

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:

 

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

 

Setting up CentOS 8

Now the WSL is set up 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):

 

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:

 

The last three lines above should be typed in as one long line. Now WSL is set up 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:

 

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.

 

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:

Then to use schemes in the profiles:

 

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. 


 

Need further help with Linux?  Contact iuvo technologies today or visit our IT services page! Need assistance with something else or want to read more informational content? Check out a few of our blogs below: