WSL 1 vs WSL 2: the background
I am Ivan Borshcov, the founder of Devforth company which delivers modern software development services. In the hint, I want to share a short history about how we have been using Windows WSL to develop Linux-compatible applications on Windows.
WSL 1 was introduced by Microsoft in 2016 and was designed like "linux compatibility layer for Windows 10". All it did at that moment – allowed running Linux binaries (ELF format) on Windows. At the same time, it already gave a Linux-compatible root filesystem (with
/home folders) which was stored inside of Windows 10 filesystem, it was just a folder tree stored somewhere inside of Windows users folder.
At that time we removed away
cygwin and started to use
apt install to run most of the software that was used on production servers. It allowed to dramatically increase the efficiency of developers who used Windows. We executed
postgresql and it all on Windows.
But we had one issue - Docker. Assuming lack of Linux kernel in WSL 1 we were not allowed to run container daemon Dockerd. Yes, we had the ability to use crunchy VirtualBox-based setups but it was hard to explain it all to developers plus it created a lot of pain.
But from June 2019, Windows 10 introduced the next version of the compatibility layer and called it WSL 2🎉. It was a dramatic change – they added a real Linux kernel and it started to use windows virtualization platform, also known as Hyper-V (or Virtual Machine Platform in newer Windows 10 builds). But it is not VirtualBox because you even don't guess about the existence of a virtual machine, it all works out of the box after a simple installation. You don't need to run it - you just work in terminal or in Visual Studio Code and feel like on Ubuntu. I did not notice any performance issues.
BTW according to my experience, the Microsoft WSL official documentation has a lot of unneeded info so I prepared a simple WSL 2 installation guide for you which is smaller plus covers all popular issues which I and my developers faced with.
One small moment after moving to Hyper-V was a change of filesystem type: in WSL 2 it started to look like on file in Windows filesystem but not as folders tree like it was before, in WSL 1:
But the good news that you can mount it as a network drive inside of the Windows:
Plus it is discoverable inside of Visual studio code using a special plugin "WSL Remote" plugin from Microsoft:
Also, to avoid any issues and understand how to work in WSL 2 I strongly suggest you read a practical WSL 2 must-read guide.