How Much Disk Space is WSL Using On Windows?
Solution 1
Determine Disk Usage From Linux
Using a tool like ncdu
can make determining disk usage easy with a nice cli interface to it as well.
Install ncdu
sudo apt install ncdu
Running ncdu
So we do not get all of Windows' directories along for the ride we'll need to exclude the /mnt
directory.
ncdu --exclude /mnt
Determining From Windows
Under Windows' Apps & Features it lists Ubuntu
as taking up 1.92 GB
ncdu
reports 1.7 GiB (~1.82GB) which is pretty close to what Windows reports.
WSL Legacy "Bash on Ubuntu on Linux"
I was not able to find how much room Bash on Ubuntu on Linux
was occupying through Windows, but I was able to see how much it was using by running ncdu --exclude /mnt
.
Related Research
Why is `du` on WSL acting giving a directory size greater than machine memory?
-
https://askubuntu.com/questions/1042285/reduce-size-of-a-wsl-installation-ubuntu-18-on-windows-10
Solution 2
The answer(s) to this question will, of course, always be changing as WSL and its distributions are updated.
It's also very difficult to measure the exact disk space utilized by any given Windows feature since Windows is constantly consuming and releasing disk space for other purposes as well. That said, here are some measurements done on Windows 11 today:
Short form:
- The WSL feature and kernel take between 100-200MB of space.
- An Ubuntu distribution takes, at a minimum 1.1GB, but will quickly expand on first update/upgrade to around 2.7GB.
- An additional ~400MB are consumed by the installed rootfs tarball, which can be recovered.
Note:
These measurements were done with the released version of WSL on Windows 11.
WSL is now available in Preview form from the Microsoft Store, and this version, when installed will consume more disk space since the features are not built into Windows. I have not yet measured the Store/Preview version of WSL.
Also, these measurements were taken with a WSL2 distribution. The initial size consumed by a WSL1 distribution will be greater than that of WSL2, however, WSL1 will release space back as files are deleted (unlike WSL2).
Details:
-
A fresh install of Windows 11 + Updates, before WSL installation, consumed
35,584,876,544
bytes of disk space. -
After enabling the WSL feature and rebooting,
35,587,739,648
bytes were consumed. A decrease of around2,863,104
(2.8MB). This is expected, since the feature is built in to Windows and is just "enabled" (not necessarily installed).Note that, at this stage, WSL1 is installed and could be used with a distribution.
-
Enabling the Virtual Machine Platform to enable WSL2 consumed an additional
23,044,096
bytes. However, rebooting actually reclaimed14,274,560
of this, for a net change of8,769,536
. Again, this smaller number is likely due to the fact that the feature ships with Windows, and is just being enabled. -
After downloading the 16.1MB WSL2 kernel package and rebooting, a whopping additional
568,856,576
was consumed. This number should be taken with a big caveat, in that Edge was launched for the first time in order to download the package. It's almost certain that most of the additional consumed disk space was from Edge features being activated for the first time and other side-effects.The kernel itself, installed, takes up
73,476,524
bytes. -
Installing Ubuntu 20.04 with
wsl --install -d Ubuntu
is certainly the biggest consumer of disk space. After installing and rebooting, an additional1,648,529,408
(1.6GB) was used.There are two main parts to this. The first is the "App" itself. This includes the rootfs tarball that gets installed. It is stored in the
C:\Program Files\
directory that is normally off-limited to your normal user. You can inspect the WSL tarball sizes, however, with a simple PowerShell one-liner run in an Administrative session:Get-ChildItem -Recurse 'C:\Program Files\WindowsApps\' | Where-Object {$_.Name -eq 'install.tar.gz' }
This shows that the tarball is
452,534,052
bytes. Technically, this could be recovered by removing the App, but be warned -- Removing the app also removes the distribution. It's possible to decouple it (through awsl --export
/--import
), though, and then remove the "App"/tarball.The other part is the actual distribution itself, which under WSL2 can be seen in the size of the
ext4.vhdx
virtual HDD. Before running any commands, the size of thevhdx
was 1,173,397,504.After a
sudo apt update && sudo apt upgrade -y
, the size of the distribution grew to2,701,131,776
(around 2.7GB). Note that adf
showed it to be1,513,688k
. The large change in thevhdx
size is likely due to the fact that the virtual disk can grow as needed, but does not release space as files are removed from it. See this question for details. -
Update for Ubuntu 22.04: The base
vhdx
size is 1.49GB. However, since it was just released today, it already includes up-to-date packages. As such, an initialsudo apt update && sudo apt upgrade -y
did not consume any additional space.Compared to Ubuntu 20.04, that's an overall savings of around 1.2GB. Again, this will likely change as we progress through Ubuntu 22.04's lifecycle.
Solution 3
@CTS_AE's answer was quite helpful. ncdu
is an excellent tool for visualizing disk usages of folders. However, ncdu --exclude /mnt
did not work for me. ncdu / --exclude /mnt
did.
I tested it on Debian (WSL2), and ncdu --version
showed ncdu 1.15.1
.
Related videos on Youtube
Comments
-
CTS_AE over 1 year
How much disk space is WSL using on Windows?
I found that you can go into Windows' Apps & Features and it will display disk usage for the WSL2 "Ubuntu", but this does not seem to include WSL Legacy or maybe it does since it seems to report more than I expect?
-
Biswapriyo over 4 yearsPossible duplicate of What size does basic Bash/WSL subsystem on Windows occupy?
-
Ravindra Bawane over 4 yearsIf you were to specify the versions of Windows you're running we could clarify that it is not a duplicate. Please use the EDIT button to make this more clear.
-
CTS_AE over 4 yearsI marked that as part of my research in the answer below. He wanted to know how much it took to install WSL to see if his system had space. He may also have been trying to gauge how much room it generally took to have a seasoned WSL set up, the accepted answer there was simply "Look at how much disk you have before you install it and find the difference", I did not find acceptable. I provided an answer on that question that links to here for how to find the actual usage, rather than trying to take a before and after size measurement. WSL is Windows 10, and I don't think subversion matters.
-
-
Ramhound about 3 years@TamusJRoyce - WSL1 has absolutely nothing to do with Android.....I have in the past fully explained what WSL1 is exactly in previous answers. WSL1 since it is no longer being improved would be considered a "legacy" implementation compared to the frequently improved WSL2.
-
TamusJRoyce about 3 yearsThat is unfortunate. I had been researching if WSL 1 was still being improved and hadn't found any articles that it was not being improved. In fact, ones that say both will remain supported. WSL 1 still has nothing to do with Linux except it can run some common commands that Linux can. I use WSL 1 often for dev work in environments where virtualization cannot be turned on. "Bash on Ubuntu on Linux" makes it sound like WSL 1 runs on Linux. Hence the comment. Thank you for the update! Greatly appreciated.
-
BJury over 2 yearsI'm pretty sure that needs to be
ncdu --exclude=/mnt
-
CTS_AE about 2 yearsThanks for this empirical process of each step. As far as I know there's no great way to measure at any given point in time, but this gives a tangible measurement, as you said will change as dependencies change over time. I was starting to wonder where the virtual disk for WSL is stored, but it's interesting that you can run an export like you mentioned.
-
Todd Sewell about 2 yearsNeither
--exclude /mnt
nor--exclude=/mnt
seems to actually exclude/mnt
, those are the first items it starts visiting. -
Admin about 2 yearsI had to exclude both
/c
and/mnt
like soncdu --exclude /c --exclude /mnt
-
Admin almost 2 yearsAt first,
--exclude /mnt
didn't work for me, but that was because the current working directory was itself inside/mnt
. It started working after runningcd /
.