How to access WSL2 filesystem when mounting the drive that the WSL2 filesystem lives on?

This sounds hacky, I know, but I just tested it and it seems to work for me ...

  • Create a new WSL2 instance of the same distro type
  • Shut it down (wsl --terminate <distroName>, wsl --shutdown)
  • Copy your salvaged ext4.vhdx over that of the new instance's (something like C:\Users\username\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState, but you probably already know that since you found the old vhdx there anyway).
  • Cross your fingers and start up the WSL instance

My "test" scenario was slightly different, of course. When I installed my Ubuntu 20.04 WSL2 distro originally, I made a backup (wsl --export) of the "pristine" filesystem. So here, I created a new distro by doing a wsl --import of that exported tarball.

I then copied my current vhdx file over the one in the newly created instance, started it up, and all my current files were present.