Skip to content

Instantly share code, notes, and snippets.

@kmatt
Last active February 4, 2025 11:04
Show Gist options
  • Save kmatt/aad3970a05f72fbbd5f1b9ef7ee1e330 to your computer and use it in GitHub Desktop.
Save kmatt/aad3970a05f72fbbd5f1b9ef7ee1e330 to your computer and use it in GitHub Desktop.
Install Void Linux on WSL2
# Based on https://gist.github.com/kmatt/71603170556ef8ffd14984af77ff10c5
# prompt ">" indicates Powershell commands
# prompt "$" are Linux shell commands
# https://docs.microsoft.com/en-us/windows/wsl/install-win10
> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
> dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# install https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
> wsl --set-default-version 2
# use rootfs tarball from https://voidlinux.org/download
# ex: https://repo-default.voidlinux.org/live/current/void-x86_64-ROOTFS-20230628.tar.xz
# uncompress but do not extract tar file (don't tar -x)
> wsl.exe --import $DISTRONAME $STORAGEPATH void-$VERSION.tar
> wsl -d $DISTRONAME
# optional - update xbps mirrors
$ cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/
# if in US https://voidlinux.org/news/2021/10/mirror-retirement.html
$ xbps-install -Su xbps
$ xbps-install -u
$ xbps-install base-system
$ xbps-remove base-voidstrap
$ xbps-reconfigure -fa
$ useradd -m -G wheel -s /bin/bash $USERNAME
$ passwd $USERNAME
# Default user
$ echo -e "[user]\ndefault=$USERNAME" > /etc/wsl.conf
# Grant sudo
$ sed -i 's/# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
> wsl --terminate $DISTRONAME
> wsl -d $DISTRONAME
@kmatt
Copy link
Author

kmatt commented Nov 16, 2023

I don't get what "uncompress but do not unzip tar file" should mean

gunzip rootfs.tar.gz but do not tar xf rootfs.tar

@roman-neuhauser
Copy link

curl.exe seems to be bundled with Windows:

C:\Users\roman>where curl.exe
C:\Windows\System32\curl.exe

and since you'll need something to decompress the rootfs anyway...

> scoop install xz

> rootfs=void-x86_64-ROOTFS-20240314.tar.xz
# the `.exe` is neccessary to disambiguate from the incompatible, half-assed PowerShell cmdlet
> curl.exe -LSfs --remote-name --no-clobber --remove-on-error \
  https://repo-default.voidlinux.org/live/current/$rootfs
> xz -d $rootfs

stripping the .xz tail from $rootfs so this dovetails with the following wsl.exe --import command is left as an excercise for the reader, i've had enough PowerShell. alternatively, you could

> rootfs=void-...tar
> curl.exe ... https://.../$rootfs.xz
> xz -d $rootfs.xz
> wsl --import ... $rootfs

@hesam-init
Copy link

Great document thanks for sharing, this distro is great for development stuff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment