Windows Subsystem for Linux (WSL2)
Windows Subsystem for Linux (WSL) allows for execution of Linux environment directly on Windows with a lot less overhead than a traditional virtual machine. WSL documentation can be found here Windows Subsystem for Linux Documentation | Microsoft Learn
Currently in version 2 (WSL2) it can be installed via simple steps and unlock Linux setup for various distributions to be processed via Microsoft Store.
It is possible to install WSL2 as described at Install WSL | Microsoft Learn via one simple command:
I do prefer though to do manual installation and select a particular distribution to install as a second step. For that we need to follow steps at Manual installation steps for older versions of WSL | Microsoft Learn
Step 1 is to enable WSL itself via following command in Windows Terminal (as admin) for example:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
You should see the following output:
Step 2 is already met when using Windows 11.
Step 3 is on enabling of Virtual Machine feature, via following command:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
You should see similar output as in Step 1.
Now, restart your system and then go back to the installation web page.
You will need to download and install the last pre-requisite from Linux kernel update package
In the main window, click Next.
Installation is really quick. Once done, click in Finish.
Next, in PowerShell, via Windows Terminal for example, set the default WSL to version 2:
wsl --set-default-version 2
Now, open Microsoft Store and install your preferred distribution.
Click in Open to launch the wizard to complete the installation.
For Ubuntu, it will ask for the credentials (username and password) to be used to configure the instance.
Once fully installed, you can launch Linux shell directly from Windows Terminal.
Hyper-V is the Windows hypervisor that provides hardware virtualization support and allows to run multiple instances of operating system, side-by-side, on top of the Windows environment you are using.
Hyper-V will enable for testing on full OS installation and some more advanced scenarios such as secure boot and virtual Trusted Platform Module (TPM).
Similarly to WSL2, Hyper-V can be installed via dism command:
dism.exe /online /enable-feature /featurename:Microsoft-Hyper-V /all /norestart
The output also expected in this case is same. Reboot to apply the changes.
After system is back online, open the start menu and search for Hyper-V. Load the application for the Hyper-V Manager.
Once the Manager opens, select the local system and click in Virtual Switch Manager.
In the next window, select New virtual network switch, External as the type and click in Create Virtual Switch.
Note: We use External switch when we want to have the virtual machine instances to “see” the interface like the external world, bring direct connected to the local network as a bridge.
Give it a name, in this case WLAN for Wireless LAN, select the external network device, in my case my AX210 card and click Ok.
Confirm the changes by clicking in Yes.
You now have completed the installation steps and have functional WSL2 and Hyper-V.