Getting Started with WSL2
I’ve finally started trying out Windows System for Linux version 2. When comparing with WSL1 it’s much faster because it works on a Virtual Machine rather than translating syscalls, but is slower when working on Windows filesystems. The speed up is significant when launching processes and dealing with small files, and git and Python virtualenvs are an order of magnitude faster. I’m still working through some of the issues of transferring.
It took me a while to try WSL2 because, as per the introductory blog post I was waiting for Windows version 2004 to appear when running “Check for Updates”. But it has been 2 months since the May release and it still hadn’t appeared. So after checking there were no known issues with my hardware, I manually downloaded the update.
After some time the upgrade installed without any issues. When I booted Docker for Windows prompted me to install WSL2, because it can now run through that. I followed the WSL2 installation instructions, and installed Ubuntu 20.04 LTS from the Microsoft Store as my Ubuntu version (I had Ubuntu 18.04 in WSL1). I then set it up with WSL2 using wsl --set-version Ubuntu-20.04 2
.
I was getting confused because wsl --set-default-version 2
wasn’t changing the default version when I checked with wsl -l -v
. This is because I was using a different distribution, and had to set the default distribution with wsl -d Ubuntu-20.04
.
Finally because I’m using the excellent Windows Terminal I set the default profile to WSL2.
Unfortunately there are a couple of things that don’t work out of the box. I can’t get Emacs working with VcXsrv, even after following these instructions for working with Emacs and WSL; it just defaults to -nw
. Another issue is that I can’t just run things on localhost in WSL and expect it to work in Windows, and have to deal with some virtual networking.
But after a few years on WSL it’s amazing to have much faster speeds and have things like emacs magit and Python virtualenvs feel usable again.