WSL2 Experience and Feelings

發表於
分類於 心得

This article is automatically translated by LLM, so the translation may be inaccurate or incomplete. If you find any mistake, please let me know.
You can find the original article here .

After upgrading to version 2004, Windows 10 can now enable WSL2. Although this is old news that I have known for a long time, I only upgraded now because I hadn't found solutions for some things I wanted.

Upgrade Method

Basically, you can refer to the official upgrade article, but you might still encounter some issues.

For example, it is recommended to run wsl_update_x64.msi with administrator privileges using PowerShell. Also, after executing wsl --set-default-version 2, it might not automatically upgrade your version, so you need to manually upgrade using wsl --set-version <Distro> 2.

Various Issues

Accessing Windows Files is Slow

This is something you should know before upgrading to WSL2. It is recommended to move your projects to the WSL2 file system for better performance, and use VSCode Remote for a more comfortable development experience. If you just want a bash for convenient file operations, you can install another Distro and downgrade to the old WSL.

Enabling Hyper-V Prevents Other VMs from Running

For VirtualBox, upgrading to version 6 or above will solve this issue as it supports using Windows' Hypervisor Platform.

For Android emulators used for gaming, it is recommended to use the Hyper-V version of BlueStacks, which can be downloaded here. Also, remember to start BlueStacks with administrator privileges, otherwise it won't work.

No Network in WSL2 When WireGuard for Windows is Enabled

I found a solution from this reddit discussion. You just need to add ::/128 to the AllowedIPs in your config.

For example, change AllowedIPs = 0.0.0.0/0 to AllowedIPs = 0.0.0.0/0, ::/128 to make WireGuard and WSL2 work simultaneously.

Docker Daemon Not Starting After Following Official Installation Process

I followed the official tutorial to install Docker, but encountered an issue where the Daemon didn't start. After some research, I found that installing Docker Desktop solved the problem, as it includes integration with WSL2.

Actual Usage Experience

The performance improvement is noticeable, for example, npm install feels faster because everything is within the Linux file system. However, accessing files under Windows is still slow, and WSL1 is needed for more normal speeds. Being able to use Docker directly is also quite convenient, and it can run some binaries that WSL1 couldn't due to certain bugs.