will changing to the "Ubuntu" app take less space on disk?
Let's get that main question handled first -- Not really. Changing the app itself that you installed from doesn't have any direct impact on the disk space.
Indirectly? Probably. But only because backing up and restoring a WSL distribution has the side-effect of "compacting" it.
Why is Ubuntu on WSL taking up so much space?
The WSL2 virtual disk image that contains Ubuntu is a dynamic Hyper-V virtual disk. "Dynamic" here means that it starts out as a near 0-byte file and grows as you add data to it. All of the Ubuntu images for WSL so far have been based on Ubuntu Server and take up around 1GB of disk space just after installing.
For instance, I just removed my Ubuntu-22.04 distribution, then, in PowerShell, re-ran:
ubuntu2204.exe
After it asks for my username and password, the resulting image is 1.1GB.
Then, after a basic sudo apt update && sudo apt upgrade -y
(the first thing you should always do after installing Ubuntu on WSL anyway), the distribution now takes ~1.7GB. Note that I'm using this PowerShell script to get the VHDX size, but you could also use File Explorer to find the ext4.vhdx
file and observe its size.
So let's say I install the Nix package manager on Ubuntu at this point, with a few of my preferred stock packages. All of a sudden the disk size jumps to ~3.8GB. Yikes! (Not really, but let's say that was too much for me). So I delete all of /nix
.
But now my disk image is still 3.8GB. Why didn't it go back to ~1.6GB?
The answer is that while the dynamic virtual disk grows to accommodate new files, it doesn't automatically shrink when those files are removed.
You can get an approximate (but not exact) idea of how much space should be consumed by Ubuntu with:
df -h /
If you find that you are really using 40GB files in Ubuntu (which is entirely possible), then there's really not much you can do other than uninstall or remove items.
However, if you are running into a situation where there's a large discrepancy between the size of the ext4.vhd
virtual disk and what you are really using in Ubuntu, then you can follow this answer for some guidance on how to shrink the virtual disk.
"Ubuntu on Windows" vs. "Ubuntu"
from what I understand ... this app shouldn't be used. Instead, the "Ubuntu" Microsoft store app can be used to run WSL.
Not really. Once you have installed any of the Store versions of Ubuntu, the Store app really doesn't "do" much any longer. It's confusing, but also read this answer for more detail. The point that the Canonical developer was making in that thread was simply that they have "renamed" the app to avoid confusion. The fact that you installed when it was called something different is quite alright and isn't something you need to "fix."
The only purpose of the Store app is to:
- Ask for your initial username and password
- Copy the "template" (rootfs) for Ubuntu into the
ext4.vhdx
- Run the distribution for the first time
In the future, when you run ubuntu.exe
or ubuntu2004.exe
(which is likely what your Start menu item is point to), it detects that it is already installed and simply skips the first two steps.
Regardless of whether you run Ubuntu, Ubuntu on Windows, Ubuntu 22.04, Ubuntu 20.04, etc. (all options, at some point at least, in the Microsoft Store), the end result is that you are running your installed version of the distribution that was created from the Microsoft Store template.
Recent releases of the Ubuntu app in the Store even allow you to uninstall the app, leaving your Ubuntu distribution intact. However, I don't know if the one you are using is new enough for this, so I don't recommend it. Regardless, the "template" files only take up around 800MB or so, so it's only worth worrying about if you are are much tighter on disk space.