WSL has become a popular choice tool of developmnet in Windows 10. With this tool you don't need to make a dual boot setup in your PC to have all the potencial of Linux because WSL gives you all what you need to start the developent ASAP, but of course WSL have some flaws like slow performance for I/O, slow file system mainly.
Microsoft released in the last main update for Windows 10 (Release 2004, build 19041 or newer) the new version of WSL, WSL 2.
The main feature of WSL 2 is giving a better performace comparing it with WSL 1, MS did a great work that they boosted up to 20x times than the original version (that's a lot! 🤯), and of course there are many features like:
- Full System Call Compatibility
- Small memory usage
- Accesing to WSL files in Windows Explorer though the network section
- And mainly, Full Linux Kernal
As I said before, you need to have Windows 10 Release 2004 Build 19041 or newer and any other Windows 10 than Windows 10 S according to MS.
First, we need to enable as usual WSL into out system and Hyper-V, a virtualization tool from Microsoft, this VM tool is needed because WSL 2 works as a kind of Virtual Machine, but in the unique way from Microsoft (this is where the magic happens)
Press the Windows key and type features and select: Activate or deactivate Windows features
An small windows with a list of features available for our system, we need to look for Hyper-V and Windows Subsystem for Linux, scroll through the list and check both options.
After both options are checked, press Accept (or OK, sorry for the spanish). Windows will start downloading the files needed, after it finishes, it will propmt to you to Restart your machine, accept the restart.
Once your machine restarted, you are ready to download Ubuntu from the Microsoft Store, search it through the Windows Store or from this link. Once the download is done, run the app, wait until the installation is ready and setup your user, we are almost done.
As you can see, this is the normal process from WSL 1, but this is the aditional step we need to do, open up Powershell and type: wsl --list --verbose, running this command should list your distro as:
Distro Status Version Ubuntu Stopped 1
As you can see, we still have WSL 1 being selected for our distro, to setup WSL 2 we need to run this command:
wsl --set-version <your-distro-name> 2, using the example should be:
wsl --set-version Ubuntu 2, it will show you a message that it will take some time to make the conversion to WSL 2, at this point you can do anything else like going for some coffee, stretch up your arms or legs, anything because it will some minutes (around 10-15 minutes).
Once the process is completed run once again the command:
wsl --list --verbose or
wsl -l -v as a shortcut, the list should display as
Distro Status Version Ubuntu Stopped 2
And now we have WSL 2 ready to rock!
By using WSL 2 we need to have some special considerations:
- Don't use any app in Windows that uses Port 53, this port is needed by Hyper-V to have access to the internet and Windows, so if you have an app like Acrylic UI, this will prevent to WSL 2 start up running.
- If you are a Laravel developer, careful by installing
cpriego/valet-linux, it will block your access to internet from your distro (I had some issues by trying to git pull a project until I found out it was the problem)
And that's it, is all for now, I hope this guide helps you with the process, see you next time around here.