Store your source code in WSL2 instead of in Windows

Written by Pim on Saturday February 6, 2021 - Comment - Permalink
Category: technology - Tag: wsl2

Windows Subsystem Linux 2 (WSL2) is the successor of WSL and includes a full Linux kernel giving users the oppertunity to run Linux software on Windows without any performance loss. I'm using WSL2 for software development purposes. My first question when using WSL2 for the first time is where to store my source code. In Windows or in WSL2? And how do you access your source code?

Store source code in WSL when running Docker in WSL

The answer to the first question is to store all source code in WSL when running Docker or any other software in WSL. I/O performance is great when using the same filesystem without any translation to or from Windows.

The answer on the second question is the use of the WSL CIFS share. This is a hidden share on Windows that is accessible when going to \\wsl$ in Windows Explorer. It shows a list of distro's that are enabled in WSL including docker-desktop and docker-dekstop-data.

Do not store source code in Windows that is needed in WSL or the other way around

It isn't that black/white but keep in mind that using Windows files in WSL and WSL files in Windows don't have great I/O performance. The main reason is because the data on Windows uses another filesystem as data that is stored in WSL. Windows uses the NTFS filesystem where WSL uses the EXT4 filesystem. Both are not compatible with each other and Microsoft has build a "translation" between the two to make both filesystems in Windows and WSL.

IDE on Windows or WSL

I use PHPStorm to develop web applications on top of the Symfony Framework. Because of the I/O penalty that is happening when accessing data from Windows in WSL, I've installed PHPStorm on WSL instead of on Windows. Read my next blog post how you can achieve this yourself!