Score:1

Understanding disk space using WSL2

no flag
a11

Complete novice here, so please tell me if this should be posted in a different forum. If the answer is already available online, I haven't been able to find it in my searches.

I set up Ubuntu 20.04 using WSL2 per the official Windows instructions. I did this because I needed to build and run a Docker container, and the instructions recommended following the WSL2 link.

After doing this, I see in the Ubuntu command prompt that the allotted disk space is 250 GB. I don't see this 250 GB allocation reflected anywhere in Windows. It previously said I had 317 GB free, and it still says that after a couple restarts. Is Windows secretly hiding 250 GB from me now, because it has been allocated to WSL? Do I really only have 67 GB free? Thank you

Score:3
vn flag

The virtual disk that WSL2 uses (ext4.vhdx) is what is known as "sparse". In other words, it appears to the underlying OS as its maximum available size, but it only takes up as much space on the host (Windows) disk as it currently needs.

You can find this file in Windows in %userprofile%\AppData\Local\Packages\Canonical..\LocalState\ext4.vhdx.

Note that space, once consumed, is not automatically released. For instance, creating a 1GB file in WSL/Ubuntu will grow the size of the virtual disk image by 1GB. Deleting that file, though, will not recover the space in Windows (but will in Ubuntu).

There are ways to manually shrink it if needed to reclaim space on the Windows drive.

a11 avatar
no flag
a11
that makes sense, thank you for the explanation info on manually shrinking
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.