The status of the previously created Ubuntu folders in Windows Subsystem for Linux (WSL)

Short answer: When you uninstalled WSL1 Ubuntu, the files you created in it were almost certainly removed as well.

More Details:

As with most Windows 10 apps installed from the Microsoft Store the App itself usually gets installed to a subdirectory of C:\Program Files\WindowsApps. This directory is protected from normal user access, so you don't typically interact with it.

Then, when you run ubuntu.exe (or one of its variants) for the first time, WSL creates an "instance" (often called "distro", but that term really should be reserved for its normal definition IMHO). That instance is installed to %userprofile%\AppData\Local\Packages\Canonical...\. The Canonical... subdirectory name will vary slightly depending on which version you installed from the Store.

All of the files that you see in the root filesystem in WSL live in the ..\Canonical...\LocalState subdirectory.

  • For WSL1, the files are actually visible in Windows itself under ..\LocalState\rootfs, but should never be accessed directly (or risk corruption).
  • For WSL2, the files live in a virtual HDD named ext4.vhdx in that same directory.

Regardless of the version, uninstalling the Store app removes both the App package in C:\Program Files\WindowsApps\... and the filesystem at %userprofile%\Local\Packages\Canonical....

I actually wasn't sure, but I tried it out on a few systems with distros that I wasn't using to confirm. I'm honestly a bit surprised, since there's a bit of an expectation that uninstalling an app shouldn't uninstall the data that goes with that app. But, with WSL distributions installed from the Store, it does.

Note that you can back up your instances quite easily, and I do so regularly, especially immediately after installing so that I have a "clean/fresh" image that I can use to create additional instances. One of the nice things about WSL is how quickly you can spin up a new instance of a distribution to try something out, then throw it away again when you are done.

The wsl --export command is used to back up an instance. It will create a tarball of all files (including system and user files) in the instance. That tarball can then be used to create a new instance with wsl --import. The nice thing about these imported images is that they are not tied to the App itself. In other words, uninstalling the Store app will not deleted instances that you created manually with wsl --import.

Coincidentally, I've been moving all of my "Store-installed" instances over to "manual" instances recently. There are also additional advantages:

  • You can create these new instances on any drive/subdirectory. It's not limited to your AppData directory.
  • As mentioned, uninstalling the Store app will not remove these instances.
  • You can name them whatever you want, such as Ubuntu20.04_WSL1

Also note that the Windows 11 version of WSL has the ability to wsl --mount additional drives (both physical and virtual). As I move to Windows 11, my plan is to see how well this will work for creating a separate drive to mount on /home, so that my user data is on a separate .vhdx than the root filesystem.