Install CentOS System on Windows 10

Windows 10's WSL, or Windows Subsystem for Linux, can run the GNU/Linux environment, including most command line tools, utilities, and applications without the overhead of a traditional virtual machine or dual-boot setup.
Windows 10 versions greater than or equal to 1709 can install and use WSL.
This article will introduce how to enable WSL on Windows 10 and install CentOS 7 or CentOS 8 system.

Turn on WSL on Windows 10

Run Powershell as an administrator and enter the following command. After a while, you will be prompted whether to restart the computer immediately. Enter Y and press Enter to restart the system.

$ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Install CentOS system

Normally, you can install some Linux distributions through the Microsoft Store, such as Ubuntu, Debian, OpenSUSE, etc., but there is no CentOS system.
At this time, you need to download a CentOS image that can be used for WSL.

Github address of CentOS image:https://github.com/mishamosher/CentOS-WSL
Address for CentOS 7:CentOS 7.9.2009
Address for CentOS 8:CentOS 8.4.2105
Address for CentOS 8 Stream:CentOS 8 Stream

Choose the image you want. Here we take downloading CentOS 8.4.2105 as an example.
What is downloaded is a zip file. Unzip it to any directory that does not contain Chinese characters, such as D:\centos8, enter its directory, right-click the CentOS8.exe file, and run it as an administrator.

Wait a moment for the installation to be completed. As shown below, you can press any key to exit the installation.

Start CentOS 8.4.2105.
Return to the decompressed directory D:\centos8, and you will see 2 more directories, as shown below.

Right-click again and run CentOS8.exe as administrator, that is, you have successfully logged in to the system as the root user, as shown below:

Perform system update, as shown below:

Note: If you find that you cannot update the system, it is most likely that the DNS has not been set up and the domain name cannot be resolved.
Execute the following command to set the nameserver

$ cat > /etc/resolv.conf <<EOF
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF

Uninstall CentOS system

Run Powershell as an administrator and enter the following command (the execution path is subject to the actual installation path):

$ D:\centos8\CentOS8.exe clean

Other available commands

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button