2

I have a SSD that went bad last weekend, and it put itself in read-only mode. I can still mount it using a rescue CD, but I can't boot into Windows 10.

I was running WSL2 on that Windows install, and I had several files living in the WSL2 filesystem. How can I access the files in the WSL2 filesystem while mounting the original drive outside of a WSL2/Windows context?

Ben Torell
  • 145
  • 6

1 Answers1

3

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.

NotTheDr01ds
  • 28,025