[WSL2/Win10] Install WSLv2

1.) Open an administrative Powershell and activate the WSL feature

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

2.) Activate the Virtual Machine Platform, afterwards reboot your computer

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

3.) Download and install the WSLv2 Linux Kernel package from https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi - another Reboot is needed afterwards

4.) Set WSLv2 as default WSL - open an administrative Powershell and enter

wsl --set-default-version 2

5.) Install one or multiple operating systems in WSLv2 - you can find them here. You can also install these "offline", meaning without the need to use Windows Store. For the offline install, download the needed package from this link, then install it by doubleclicking on the Icon - or via Powershell with

Add-AppxPackage .\app_name.appx

You can then start and use it :).

Its also not a bad idea to install Windows Terminal.

[WSL2/Win10] virt-manager for kvm on Windows

kvm Virtualisiation is great, however, useable tools to create and manage said VMs are rare. The best tool for the job, virt-manager is only available for Linux machines. But what if you want to manage said VMs also via Windows 10? WSL2 to the rescue: Just install WSL2 as shown by the excellent Microsoft Guide, install i.e. a Debian/GNU Linux instance and then launch into it.

You should update the instance to the latest version first:

sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade -y

then you can install virt-manager

sudo apt install -y virt-manager ssh-askpass

the last thing you would need is to install an X server on your windows machine, i.e. Xming or MobaXterm (which contains Xming) and launch it. Then you need to setup the X forwarding in your WSL2 instance, by entering

export DISPLAY="grep nameserver /etc/resolv.conf | sed 's/nameserver //':0"
export DISPLAY="sed -n 's/nameserver //p' /etc/resolv.conf:0"
export DISPLAY=$(ip route|awk '/^default/{print $3}'):0.0

after that, you can launch virt-manager by entering

virt-manager

and configure it to connect to your KVM instance via SSH.

[Win10] Random ports blocked while using Docker / WSL / HyperV

I have been using Windows Subsystem for Linux (WSL) and Docker on my Laptop since a long time. And during last Docker Con, WSL 2 was released to which I switched instantly - which I did not regret.

(Note: Upgrading to WSL 2 and the native Docker for WSL 2 version will cost you your containers and Docker images, there is even a Thanos meme coming around - so I have to give this fair warning ;))

However: Said Laptop started acting strange as suddenly local MariaDB instances or Apache2 did cease to work and even some nodeJS projects on port 9000. All these ports were not taken directly by any application, but somehow it did not work anymore. It turns out that a faulty HyperV update led to the hypervisor reserving too many ports across the board.

Luckily there is a solution to correct this issue as shown here by Christopher Pietrzykowski.

To make it easy and fast: Open up a powershell or cmd prompt as admin user and enter

netsh int ipv4 show dynamicport tcp
netsh int ipv6 show dynamicport tcp

If it comes up with startport 1025 and a huge number of reserved ports, you are experiencing the same problem. Please enter these commands to realign the startport to 49152 for both IPv4 and IPv6

netsh int ipv4 set dynamic tcp start=49152 num=16384
netsh int ipv6 set dynamic tcp start=49152 num=16384

after a reboot, everything should be fixed again 🙂

Upgrade WSL (Windows Subsystem for Linux) on Windows 10

I had installed WSL (Windows Subsystem for Linux) a long time ago to gain access to Ubuntu 14.04 LTS directly from my Windows 10 Desktop. However, as time passes, Software grows old. Upgrading the Ubuntu Subsystem via apt-get update / do-release-upgrade should work, but that could have some nasty sideeffects, considering that the 14.04 LTS WSL release had been a beta test - so, a reinstall should be better.

Luckily, TechRepublic got this covered. Just open a CMD and run:

lxrun /uninstall /full /y

to uninstall the current WSL version.

Afterwards, try

lxrun /install

to reinstall it. With this "reinstall", Ubuntu 16.04 LTS will be installed.

Nonetheless, I recommend a nice

sudo apt-get update
sudo apt-get dist-upgrade

afterwards in your BASH session to get the WSL to the latest version ;).