2

I recently switched over from the legacy Docker desktop for windows(Hyper-V) to the WSL 2 based version. I am running out of space on my hard drive and noticed a folder at C:\Users\Public\Documents\Hyper-V that is very large (> 80 GB). Is it safe to remove that?

dovidweisz
  • 193
  • 2
  • 8

1 Answers1

1

WSL doesn't use the HyperV location to save data. You can verify this by typing the below command in PowerShell as mentioned here

(Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | ForEach-Object {Get-ItemProperty $_.PSPath}) | select DistributionName, @{n="Path";e={$_.BasePath + "\rootfs"}}

This should print out where the data for your WSL2 distro is saved on the drive. Once you've verified it doesn't point to the Hyper-V directory, you can delete it off.


It is fine to delete them by hand, if you're never going to use them. Removing the VM in Hyper V manager should also delete the VHDs, which is the safer way, but I can't recall if WSL2 install requires disabling Hyper-V, which means you can't use Hyper-V manager. If you can use Hyper-V manager by installing it from Windows features, by all means install and remove the images using that.

Sathyajith Bhat
  • 61,504
  • 38
  • 179
  • 264
  • So is it safe to assume that the Hyper-V location is old and stale data? – dovidweisz Aug 26 '21 at 15:36
  • Agreed that WSL does not use Hyper-V, but the question is whether it is safe to delete data left over from a Docker Desktop installation that used Hyper-V rather than WSL (after switching to WSL). And is the correct way to do it by deleting the folder itself? Or should Hyper-V by used to remove the images? I tend to think that deleting Hyper-V files from outside the manager would result in Hyper-V being in a bad state, but not sure. – NotTheDr01ds Aug 26 '21 at 23:13
  • I updated my answer, @NotTheDr01ds. it's safe to delete if you're not using them. – Sathyajith Bhat Aug 28 '21 at 07:39
  • @SathyajithBhat Thanks - That's what I was saying in the comments on the question itself. It's safer to delete through Hyper-V. And yes, Hyper-V can be enabled alongside WSL2 without any problem, assuming Windows Pro or higher. WSL2 and Hyper-V use the same underlying system at the core, but work together just fine. I just couldn't remember if Docker Desktop using Hyper-V required Pro, but a quick search seems to confirm that it did. So the OP should use Hyper-V Manager to delete the files. – NotTheDr01ds Aug 28 '21 at 13:43