2

I've installed WSL2 on Windows 10 Pro.

I am not sure how I came up with that split between WSL and C:, but basically now my WSL seem to have a partition too big (250GB) for what is needed (~15GB), so I'm left with 235GB free on WSL while my C: drive is getting full (only ~6.7GB free) ...

I would like to reallocate some of the 250GB disk space allocated to WSL, back to my Windows C: drive.

Does anyone have a clean solution please?

Screenshot of my drives as they appear in "This PC":

Screenshot of my drives as they appear in "This PC"

1

1 Answer 1

2

Well here's the good news -- You didn't accidentally allocate 250G to WSL. WSL2 allocates what is known as a "sparse" virtual disk. That means that internally, it appears at it's maximum size (250GB in this case). However, externally what is really being used is entirely different. When empty, a sparse disk will actually take up 0 bytes on the host drive.

You can see an example of this from within WSL with the following:

> cd ~
> dd if=/dev/zero of=sparse_file bs=1 count=0 seek=512M
0+0 records in
0+0 records out
0 bytes copied, 3.9604e-05 s, 0.0 kB/s
> ls -lhn sparse_file
-rw-r--r-- 1 1000 1000 512M Nov 25 19:10 sparse_file
> du sparse_file
0       sparse_file
> rm sparse_file

The file appears to be 512MB, but du (disk usage) shows that it really takes 0 on the disk.

So when you view the filesystem through the \\WSL$\ network share, it's simply showing the maximum possible size to which the virtual WSL2 disk can grow.

You can see how much space the WSL2 virtual disk is actually taking by searching your drive for ext4.vhdx. It will be in something like %userprofile%\AppData\Local\Packages\<DistributionPackage>\LocalState. For Ubuntu, for instance, the "DistributionPackage" will be something like CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc (but will change depending on the release).

If the size of the virtual disk really is much larger than you expect, then this is likely because the sparse file will grow as space is used within the virtual disk, but it will not shrink when you remove files.

You can reclaim this space in several ways. Please see this answer for details on that, if needed.

Well that's the good news. The bad news is that (assuming it isn't WSL) you'll need to find what is actually taking up all that space on your Windows drive. There are a few ways to do this. You might start with the "Storage" settings in Windows, but you may need a more detailed analysis as well.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .