Fix WSL2 issues to access folders

TL, DR

Windows Subsystem for Linux version 2 (WSL2 for its friends) is a great tool developed by Microsoft that let you use a full Linux system fro within your windows machine. However, sometimes WSL2 may have issues to access some Windows folders. Rebooting WSL2 is often the quickest fix.

Windows Subsystem for Linux

In 2019 Microsoft introduced Windows Subsystem for Linux version 2 (WSL2 for its friends). It was a groundbreaking feature that enabled a true Linux kernel inside your Windows environment, that tremendously help most Software Development processes.

This means that you can execute Linux commands from your windows machine, install Linux applications and effectively developing in the Linux world.

WSL2 comes with full access to your Windows files. The recommended way to access them from within the terminal is to use the /mnt directory. From your WSL2 terminal you can type:

cd /mnt
ls

Those two commands will list the disk present in your machine. In my case, that was the result:

WSL2 /mnt listing
WSL2 issues access folders
WSL2 /mnt listing

As you can see, I have three disks (the equivalent of C: , D: and E: in windows).

However, after a power off/power on cycle (not reboot, but actually turning my Windows machine off and turning it on again the day after) I could not access anymore some of my folders.

I searched the internet, and the quickest fix I could find was to reboot WSL2. In order to do so, you need to open a Powershell terminal and issue the following commands:

wsl --shutdown
wsl

The first one will turn off WSL2, the second will restart it again. If you have some other service that depends on WLS2 (like Docker Desktop, for example), you will need to restart those as well.

Probably the culprit for the malfunctioning is the Windows Fast Startup functionality…but until deeper debugging it’s only an hypothesis. So it seems the old trick to reboot and cross fingers is still a proper process in the Windows world!

  • WSL2 general info link
  • Thread on GitHub about WSL2 issues to access folders link

Do you like our content? Check more of our posts in our blog!