2022-12-30
A few tweaks I've found to make WSL just a little more awesome.
You've played with WSL before
https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux
https://learn.microsoft.com/en-us/windows/wsl/about
Used to be like WINE or Cygwin in reverse, pretty cool.
Eh, just make it a VM.
Ok, that's not fair. Virtualised, like a VM, but different. Reverse WINE is just way more cool to me, but v2 does work better / faster, and works with the whole virtualisation-based security thing, might be some security type cool stuff in the pipeline.
That said, at time of writing, it's not a security boundy, nor intended to be one. Stuff runs in the context of the parent process (you!)
That does not include Ubuntu.
Not these either
https://learn.microsoft.com/en-us/windows/wsl/install-manual
wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl --install -d <Distro>'.
NAME FRIENDLY NAME
Ubuntu Ubuntu
Debian Debian GNU/Linux
kali-linux Kali Linux Rolling
SLES-12 SUSE Linux Enterprise Server v12
SLES-15 SUSE Linux Enterprise Server v15
Ubuntu-18.04 Ubuntu 18.04 LTS
Ubuntu-20.04 Ubuntu 20.04 LTS
OracleLinux_8_5 Oracle Linux 8.5
OracleLinux_7_9 Oracle Linux 7.9
You can use a vanilla container image, clean and minimal, only install what you need.
https://learn.microsoft.com/en-us/windows/wsl/use-custom-distro
Distro | Source |
---|---|
Rocky Linux | https://docs.rockylinux.org/guides/interoperability/import_rocky_to_wsl/ |
CentOS Stream | https://cloud.centos.org/centos/ |
Arch Linux | https://gitlab.archlinux.org/archlinux/archlinux-docker/-/releases |
:: check if you have WSL installed, and any distros
wsl --list
:: import the image (auto creates the directory, there's a VHDX in there)
wsl --import "myRockyLinux01" "C:\Users\xxx\AppData\Local\Programs\WSL\myRockyLinux01" "C:\Users\xxx\Downloads\Rocky-9-Container-Base.latest.x86_64.tar" --version 2
:: should now see your new install
wsl --list
I have another install already
:: should log you in as root
wsl
:: can make another account later
Won't have much installed, just the basics
It's like any other Linux box at this point, do some updates, install what you need to get started.
dnf -y update
dnf -y install epel-release
dnf -y install vim bind-utils curl wget tree ncdu ncurses iproute
Give this a good read, make your own decisions.
https://learn.microsoft.com/en-us/windows/wsl/wsl-config
I landed on the following, your use case might be different.
Big performance gain came from disabiling nested virtualisation and interop.
/etc/wsl.conf
[boot]
systemd=true
[automount]
enabled = true
[interop]
enabled = false
appendWindowsPath = false
[wsl2]
nestedVirtualization = false
[user]
default = notroot
wsl --terminate myRockyLinux01