Short answer: wsl --unregister <distro> (from PowerShell or CMD, a non-admin session) should remove the distribution, all files in it, and the share.
More detail:
Some brief history and background is needed to understand what's going on. When you install a distribution (e.g. Ubuntu) in WSL, two things get installed:
First, the Store package itself (in C:\Program Files\WindowsApps\<distroPackage>). You can see this by going to an Admin PowerShell and running:
Get-ChildItem -Recurse 'C:\Program Files\WindowsApps\' | Where-Object {$_.Name -eq 'install.tar.gz' }
Then, when you start the distribution for the first time (e.g. ubuntu.exe or ubuntu2204.exe, etc.), it installs the actual rootfs and registers the distribution. You can see these with (no Admin required):
Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss\ |
ForEach-Object {
(Get-ItemProperty $_.PSPATH) | Select-Object DistributionName,BasePath
}
There was a time, under Windows 10 (and it may still be the case) that when you uninstalled the Store package (via "Add or Remove Programs" or a right-click "Uninstall" on the Start Menu item) that it would also uninstall the distribution files.
That was bad.
For starters, the "Uninstall" info for Store apps in Windows says, "Your documents will not be affected", which wasn't true for WSL distributions. This caused loss of data, for at least this user.
At some point, and I believe it was in Windows 11, this changed so that uninstalling the Store package, like you've done, did not remove the distribution and its files. I think this is a better approach.
Now, you remove a WSL distribution in two, independent steps:
- Uninstall the Store Package
wsl --unregister the distribution
I would still, being paranoid, recommend a backup of a distribution (wsl --export) before removing the Store package. Just in case ...
wsl -l -v. – Daniel B Oct 08 '22 at 18:20