WSL:- Provision CentOS

Background

Let us quickly provision CentOS using WSL on a Microsoft Windows 10 system.

 

Microsoft WSL

Linux Distributions

Here are the Linux Distros that are officially supported by Microsoft WSL.

NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
openSUSE-42 openSUSE Leap 42
SLES-12 SUSE Linux Enterprise Server v12
Ubuntu-16.04 Ubuntu 16.04 LTS
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS

WSL Commands

WSL –list

To get the Linux Distros availed for your working system, please use the “WSL –list” command.

Outline

  1. wsl –list
    • See available Linux Distros
      • wsl –list –all
    • See all published packages
      • wsl –list –online
    • See Linux Distros currently running on your machine
      • wsl –list –running

Command

wsl –list –all
Syntax

wsl --list --all

Sample

wsl --list --all

Output – Image

Output – Text

Windows Subsystem for Linux Distributions:
Ubuntu (Default)

wsl –list –online
Syntax

wsl --list --online

Sample

wsl --list --online

Output – Image

Output – Text

The following is a list of valid distributions that can be installed.
Install using ‘wsl –install -d <Distro>’.

NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
openSUSE-42 openSUSE Leap 42
SLES-12 SUSE Linux Enterprise Server v12
Ubuntu-16.04 Ubuntu 16.04 LTS
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS

wsl –list –running
Syntax

wsl --list --running

Sample

wsl --list --running

Output – Image

Output – Text

There are no running distributions.

CentOS

Introduction

From running “wsl –online” and reviewing the list of published packages, centOS is obviously missing.

Workarounds

Are there workarounds that will assist us to avail CentOS as one of the Linux Distros available to WSL?

Yes, there is.

Elmer Miroslav Mosher Golovin

Thankfully, Elmer Miroslav Mosher Golovin ( mishamosher ) has a well-received GitHub repository that avails the binaries for tying WSL and CentOS.

The account’s URL is https://github.com/mishamosher.

Repository

Here is the URL to his CentOS-WSL repository https://github.com/mishamosher/CentOS-WSL.

CentOS Version

Golovin’s currently avails releases for the following CentOS versions:-

  1. CentOS 8-stream
  2. CentOS 8
  3. CentOS 7
  4. CentOS 6

CentOS 8-Stream

We are going to go with the latest release and the URL for that release is https://github.com/mishamosher/CentOS-WSL/releases/tag/8-stream-20210603

Asset
Image

Text

The file we need is CentOS8-stream.zip.

It is a 500 MB file.

 

Extract

Please extract the compressed package ( CentOS8-stream.zip ).

Upon extraction, two files are availed.

The files are:-

  1. CentOS8-stream.exe
  2. rootfs.tar.gz

Generate Hyper-V Virtual HardDrive ( VHDX )

Please run CentOS8-stream.exe to generate a Hyper-V virtual hard drive.

The name of the Hype-V VDHX file that will be created is ext4.vhdx.

Command – CentOS8-stream.exe
Syntax

CentOS8-stream.exe

Sample

CentOS8-stream.exe

Output – Text

>CentOS8-stream.exe
Using: C:\Downloads\mishaMosher\centOS\v8\stream\CentOS8-stream\rootfs.tar.gz
Installing...
Installation Complete!
Press any key to continue...

Output – Image
Explanation

When we run CentOS8-stream.exe it accesses the rootfs.tar.gz and creates a VDHX file ( ext4.vhdx ).

 

Use Hyper-V Virtual HardDrive ( VHDX )

Please run CentOS8-stream.exe to utilize the created Hyper-V file ( ext4.vhdx ).

Command – CentOS8-stream.exe
Syntax

CentOS8-stream.exe

Sample

CentOS8-stream.exe

Output – Text

>CentOS8-stream.exe
ERROR:[2] Could not read registry key
[root@computername ~]#

Output – Image
Explanation

By using the same command, CentOS8-stream.exe, we previously used to create a VDHX file, we are able to initiate a centOS runtime.

 

Validation

Let us run a couple of quick validation tests.

Tests

  1. Get OS Name
    • File
      • /etc/os-release
    • Command
      • lsb_release -a
      • hostnamectl

Get OS Name

File – /etc/os-release
Syntax

cat /etc/os-release

Sample

cat /etc/os-release

Output – Text

>cat /etc/os-release
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
>

Output – Image

Command – lsb_release
Syntax

lsb_release

Sample

lsb_release -a

Output – Text

-bash: lsb_release: command not found

Output – Image

 

Command – hostnamectl
Syntax

hostnamectl

Sample

hostnamectl

Output – Text
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to create bus connection: Host is down

Output – Image

Explanation

Traditionally there are a few ways of determining the current OS Version.

Those ways are via examining files ( /etc/os-release ).

Other ways are through commands ( lsb_release, hostnamectl ).

For WSL, examining the file /etc/os-release works.

Unfortunately, the traditional commands ( lsb_release, hostnamectl ) does not work.

Dedication

In dedication to Elmer Miroslav Mosher Golovin.

 

Summary

Confirmed that even though we are using a different Linux Version, centOS, than the original version, Ubuntu, that I used during my initial post on WSL, still experiences the same problem with DNS resolution.

BTW, that post is here:-

WSL:- Networking Issue – Day 01
Link

And, the specific error message reads “Name or service not known“.

In later posts, we will cover more WLS configurations and stumbling.

But, for now, like Chante Moore, I got a (wo)man.

Link

 

References

WSL

  1. LinuxHint
    • Sharqa Hameed
      • How to install CentOS using WSL
        Link

Linux Version

  1. Linuxize
    • How to Check Linux Version
      Link

 

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s