Does WSL2 run Linux in a virtual machine or alongside the Windows kernel?
I've always wanted a Linux terminal in Windows and was fulfilled by WSL 1. But it was painfully slow as it was (I guess) a Hyper-V-managed virtual machine. With WSL 2, it's way faster relatively but I cannot understand how Microsoft made it so.
Did they improve Hyper-V or did they stop using a virtual machine and create some magic to run the Linux kernel in parallel?
From the article About WSL 2 of Microsoft Docs:
Brief overview of the WSL 2 architecture
WSL 2 uses the latest and greatest in virtualization technology to run its Linux kernel inside of a lightweight utility virtual machine (VM). However, WSL 2 will NOT be a traditional VM experience. A traditional VM experience can be slow to boot up, is isolated, consumes lots of resources, and requires your time to manage it. WSL 2 does not have these attributes. It will still give the remarkable benefits of WSL 1: High levels of integration between Windows and Linux, extremely fast boot times, small resource footprint, and best of all will require no VM configuration or management. While WSL 2 does use a VM, it will be managed and run behind the scenes leaving you with the same user experience as WSL 1.
As how we can see in the following articles (and discussions below them) WLS 2 uses Hyper-V feature:
- Microsoft devBlogs: WSL 2 is now available in Windows Insiders
- Thomas Maurer blog: Install WSL 2 on Windows 10