A quick not to my future self, on how to unfuck #wsl2 root file system:
- Find the location of your disk image, for Ubuntu it would be something like
C:\Users\aleks\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\ext4.vhdx
. - Make a fucking backup!
- Install a new wsl distro. Could be anything, if you have Docker Desktop, you probably already have
docker-desktop
distro, which would do. - Connect the image to our recovery distro:
wsl -d docker-desktop --mount --vhd C:\Users\aleks\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\ext4.vhdx
- Go into the recovery distro:
wsl -d docker-desktop
. - Figure out which device your image corresponds to:
ls /dev/sd*
. - Unmount it:
umount /dev/sdX
. - Actually unfuck the image:
e2fsck /dev/sdX
. - Exit wsl and shut it all the way down:
wsl --shutdown
. - With any luck, you can start your main distro and it will be fine.