WSL 2 virtual hard drive issues
Getting straight into it, WSL has its share of problems compared to native linux - but we’re getting there.
In this post, I address the issue of deleting large files and still not having the space claimed back by the host OS. ( or at least this is the case when you notice it)
What really happens is , your linux distro does free it from its own file system (ext4 by default). However, this storage exists as a virtual hard disk in your windows file system (NTFS by default).
Hence, when you delete a large file or a large number of small files using rm or unlink in WSL, you’ll notice that the space is not freed up in your host OS partition.
If you google a bit in the context of linux, you’ll find solutions directing you to …
lsof | grep deleted
… and then get to the corresponding pid in /proc/ and delete that file.
Well.., that is not the case here.
If you examine your disk usage using du
or GUI analysers such as baobab
, you’ll notice that, you have the space freed in your distro.
However, when you check on your windows file system - it’s the same. The first time this happened to me, I racked my brains off for a day and finally decided to re-setup my environment : deleting the current virtual hard disk altogether.
Today, things could go down the same lane.
-
But, once I’d found a problem, it wasn’t difficult to dial down on the solution : one of them being to use Window’s Hyper-V management to optimize the vhd.
-
But, that needed windows 10 pro or education. I didn’t want to make a rash decision. Who wants to purchase an upgrade to fix a “problem” of the current version ( I have the home version ).
-
But, now that I am a better human in all respects and sport a longer beard ( and hence greater accompanying patience ) : I googled a bit more and found this
-
And now, I’m happy.
Leave a comment