DateApr 10, 2021

WSL - Making Windows Harder to leave

Yeah, I know what I am saying. If someone would have told me this 2 to 3 years ago, I would have lambasted the symbol of ignorance, off his pants. However since Windows has started embracing Open Source more and more, their developer offerings have been getting much better.

💡
Visual Studio Code, GitHub, Windows Subsystem for Linux(WSL) - are pretty popular and awesome offerings by Microsoft.

There was a time when Microsoft was cut-throat against Open Source. Understandably so! as it directly challenged the paid offerings by Microsoft. But things have since changed and Microsoft has become one of the pioneers in Open Source.

One of the newest and astounding Open Source services is WSL - Windows System for Linux.

What the heck is WSL?

WSL itself is not open source. It ships along with Windows 10 and allows you to run many Linux-based Distros directly on a Windows machine without suffering from the overhead of a Virtual machine.

Gone are the days of dual-booting Windows!!?

💡
Windows has released a new version of WSL - WSL2 with improved performance and integration with Windows. It has better File System performance as well as adds full system call compatibility.

Bang for the bucks

WSL offers a great set of enticing features. Some of them include:

  1. Ability to run a wide range of distros - Kali, Ubuntu, Alpine, OpenSuse, etc. You can even have them installed simultaneously! Good luck installing them via VM on a single middle-spec machine.
  2. You can open the distro file system in Windows Explorer and vice versa. It's like both of them are working simultaneously (and they are!)
  3. Ability to forward ports - any application you run on localhost of a distro is automatically available on Windows localhost. So if you have a nodeJS application running on port 3000 inside the distro can be accessed on http://localhost:3000 on a Windows.
  4. Awesome integration with VS Code! You can directly have your development workflow on Windows and have it interfaced with your distro.

How to get WSL on your machine?

To update to WSL 2, you must be running Windows 10.

  • For x64 systems: Version 1903 or higher, with Build 18362 or higher.
  • For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
  • Builds lower than 18362 do not support WSL 2. Use the Windows Update Assistant to update your version of Windows.

You can follow the official guide for installation -

For the lackies, here's a short guide -

Step 1 - Enable the Windows Subsystem for Linux and VMs.

Option #1 - You can use the "Turn Windows Features On/Off" settings. Just search for the same in the Start menu. Check the options - Windows Subsystem for Linux and Virtual Machine Platform.

Option #2 - Open Windows Powershell as administrator and execute the following commands.

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Restart your machine after following any of the above options.

Step 2 - Set wsl2 as default.

Open PowerShell and run this command to set WSL 2 as the default version when installing a new Linux distribution:

wsl --set-default-version 2

If the command fails, it most likely means that you don't have WSL-2 but the older WSL-1 installed. Follow this step on the official guide to install the same.

Step 3 - Install Linux Distro of your choice

Open the Microsoft Store and select your favorite Linux distribution.

The following links will open the Microsoft store page for each distribution:

Troubleshooting

Although most of the scenarios are covered in the official documentation -

Here are some of the issues that I sometimes face -

# Port Forwarding does not work

Plan A: Restart the LxssManager service from the Services manager. To open this application, you can simply search services in windows search.

Plan B: If the above does not solve the problem, you may need to reset your network. Again simply search network resetin Windows search bar.

This usually resets your Network statistics but does not remove wifi passwords and all
This usually resets your Network statistics but does not remove wifi passwords and all

Restart your machine!

# Duplicate *.identifier files being generated in your Distro FS

These are harmless and it's safe to delete them.


That's all! Those are the only issues I have faced with WSL. Not bad right!?

So Finally!

I am no Windows fanboy, but Microsoft has been spinning up the Open Source game. Having said that! With the new Apple Silicon, it's hard to go for any Windows-based computer. But WSL is something that other OEM developers can include in their offerings.