In this short post, I want to go over how to install Void Linux on WSL.
Pre-requisites
- WSL installed (docs here)
- A Powershell terminal session (or another wsl distro if you’d rather invoke wsl.exe that way)
Installation
First, download the latest Void Linux rootfs tarball from here.
$ mkdir void-install
$ cd void-install
$ wget https://repo-default.voidlinux.org/live/current/void-x86_64-musl-ROOTFS-20221001.tar.xz -o void-x86_64-musl-ROOTFS-20221001.tar.xz
Then, we can import the rootfs as a WSL distro and run it1. Note that you will need to decide on a location for custom imported distros to go. I usually just create a folder named WSL-Custom under my user. You can select any name for the distro, here I picked “Void”.
$ wsl --import Void <custom-folder-for-your-distros> .\Downloads\void-x86_64-musl-ROOTFS-20221001.tar.xz
$ wsl -d Void
This will get you into a root shell. Let’s add a user with sudo privileges and set it as default in WSL:
# useradd -m -G wheel -s /bin/bash $USERNAME
# passwd $USERNAME
# echo -e "[user]\ndefault=$USERNAME" > /etc/wsl.conf
# sed -i 's/# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
Now we can restart WSL by exiting the distro and running wsl --shutdown
. Once you run the distro again, you should get a shell as your new user.
Post-installation
There are a few things that I do after the initial installation:
- Update xbps and installed packages
$ sudo xbps-install -u xbps
$ sudo xbps-install -Su
- Copy my ssh private key from Windows so that I don’t have to add a new key per distro onto github/gitlab:
$ mkdir .ssh
$ cp /mnt/c/Users/nadim/.ssh/id_ed25519 .ssh
$ chmod 0600 .ssh/id_ed25519
- Install packages:
$ sudo xbps-install base-devel git neovim ripgrep fd
References
-
This is the recommended way to import a linux distribution into wsl ↩︎