CentOS WSL2
Enabling WSL2
-
Enable WSL
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart -
Enable Virtual Machine Platform feature
Required for WSL2.
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart -
Set default WSL version
(Optional)
wsl --set-default-version 2
Import CentOS image
-
Download latest image named
CentOS-8-Container-8*.x86_64.tar.xzfrom http://cloud.centos.org/centos/8/x86_64/images/. -
Extract
layer.tarfile from the downloaded archive. -
Import the image
wsl --import centos8 opt\wsl\centos8 layer.tar --version 2The first argument
centos8is name that will be later used to reference this distribution.The second argument
opt\wsl\centos8is path to a directory (it may not exist, the parent directory must) where the distribution will be installed in.The third argument
layer.taris path to the extracted system image.Import can be verified by listing all available distributions:
PS > wsl -l -v NAME STATE VERSION centos8 Stopped 2
Running the distribution
wsl -d centos8
The centos8 is distribution name used when importing the image.
Provided a distribution is marked as default by
wsl --set-default centos8
it can be later invoked just by
wsl
Custom user
The image doesn’t define any extra users so bash will start under root user. If you create your own user, WSL can be configured to be start using this user - see guide Add your user part of Using Fedora 33 with Microsoft’s WSL2 article.