Install Void Linux on WSL2
Contents
About
Windows 10 version 1909 is finally available for my surface device, I’ve waited for it for several months since there is a very important new feature: WSL2
IMO, WSL1 is not suitable for daily development because the performance is TOO BAD. Can you imagine I spent 15 minutes but still cannon launch neovim while it only took about 100 milliseconds in physical arch linux?
Compared to WSL1, the performance of WSL2 has been greatly improved. I think it’s time to try WSL again.
This time I decided to try void linux. Void linux is an independent rolling release linux distribution, it uses runit as its init system instead of systemd which is generally used in most of distros. Systemd has caused a lot of controversy in the linux community. I personally don’t like it either, I prefer openrc which is developed by gentoo. But looks like runit is also a great alternative to systemd, it might be worth trying, although I’m not sure if it works in WSL2.
Another great feature of void linux is that it officially supports both glibc and musl libc. Musl libc is an implementation of the C standard library. Compared to glibc which is used in most of the distros, musl libc is more lightweight and is written with more security in mind. Here is a detailed comparison: https://www.etalabs.net/compare_libcs.html
Preparation
To begin with, follow this official guide to enable WSL2: https://docs.microsoft.com/en-us/windows/wsl/install-win10
Then download the x86_64-musl
rootfs tarballs: https://alpha.de.repo.voidlinux.org/live/current/
And verify it:
Open powershell and execute
|
|
Compare the output of this command with sha256.txt.
Installation
First of all, install Ubuntu on WSL1:
- Install Ubuntu from Microsoft Store: Ubuntu
- Make sure Ubuntu is installed on WSL1 instead of WSL2:
wsl --set-version Ubuntu 1
- Make sure the default user is root:
ubuntu config --default-user root
Now, launch ubuntu from the Start Menu.
Extract the tarball:
|
|
You may want to change the mirror of void linux:
|
|
Let WSL generate /etc/resolv.conf
automatically:
|
|
Exit Ubuntu.
Open windows file explorer, navigate to %localappdata%\Packages
and find CanonicalGroupLimited.UbuntuonWindows_*
.
In %localappdata%\Packages\CanonicalGroupLimited.UbuntuonWindows_*\LocalState\rootfs
, delete bin
, etc
, lib
, lib64
, lib32
, libx32
, sbin
, usr
and var
.
Move (Don’t copy) bin
, etc
, lib
, sbin
, usr
and var
from rootfs\root\
to rootfs
.
Launch ubuntu again.
Delete useless files in /root
|
|
Install base-system:
|
|
Go through the options in /etc/rc.conf
:
|
|
Set a root password:
|
|
Create a new user:
|
|
Use xbps-reconfigure to ensure all installed packages are configured properly:
|
|
Exit ubuntu.
Open powershell and set default user:
|
|
Set WSL version to WSL2:
|
|
Now we get a void linux on WSL2
Post Install
Next you can follow the official guide to configure void linux: https://docs.voidlinux.org/config/index.html