Snap and Flatpak keep more than the apps you see. Snap keeps old revisions of every snap after each update, Flatpak keeps runtimes that no app needs any more, and both give each app its own cache folder in your home. On an Ubuntu install a year or two old, that is often several GB. The /dev/loop lines at 100% in df are snaps mounted read-only and are normal; when the disk looks full for other reasons, see Ubuntu says the disk is full, but df shows free space.
See how big they are:
sudo du -sh /var/lib/snapd/snaps /var/lib/flatpak ~/.local/share/flatpak 2>/dev/null
du -sh ~/snap/*/common/.cache ~/.var/app/*/cache 2>/dev/null | sort -h | tail -15
Old snap revisions
snap list --all # every revision; old ones say "disabled" in Notes
snap list --all | awk '/disabled/{print $1, $3}'
Each snap update leaves the previous revision on disk so snap revert can go back. Ubuntu keeps 2 revisions per snap by default, which can grow to 3 while an update runs. Remove the disabled ones:
snap list --all | awk '/disabled/{print $1, $3}' |
while read -r name rev; do sudo snap remove "$name" --revision="$rev"; done
Close the apps first: a revision of a running snap can’t be removed. The revision you run is never disabled, so it stays.
Keep fewer revisions
snap get system refresh.retain # empty means the default, 2
sudo snap set system refresh.retain=2
2 is the lowest value snapd accepts (up to 20). With it, each snap keeps the current revision and one to go back to, and the next updates stop old ones piling up.
Snap doesn’t run inside a Docker container, so these commands are written from the snap documentation; run them on a real Ubuntu install.
Unused Flatpak runtimes
flatpak list --runtime # GNOME, KDE, freedesktop runtimes and GL drivers
flatpak uninstall --unused # runtimes and extensions no installed app uses
flatpak repair # fix missing objects and remove unreferenced ones
A Flatpak app depends on a runtime (for example org.gnome.Platform//46). When the app updates to a newer runtime or you uninstall it, the old runtime stays until flatpak uninstall --unused. It asks before removing anything. Add --user or --system (with sudo) to work on one installation only. flatpak repair is for a broken or bloated store; it can take a while.
App caches
- Snap:
~/snap/<name>/common/.cacheand~/snap/<name>/current/.cache. - Flatpak:
~/.var/app/<id>/cache.
Caches are rebuilt when needed, so deleting them is safe once the app is closed. Don’t delete the whole ~/snap/<name> or ~/.var/app/<id> folder of an app you keep: it also holds its settings and data. Folders of apps you already removed are leftovers; see uninstall apps completely.
How CleanMate does it
On Ubuntu (all Ubuntu features):
- Smart Scan › System Junk › Old Snap revisions: the disabled revisions, removed with
snap remove --revision; the revision you run is never removed. - Smart Scan › User & App Junk: the caches of Snap and Flatpak apps, each app as its own choice.
- Maintenance: remove unused Flatpak runtimes with a Run button and its output in a log window, and a switch that keeps fewer snap versions (
refresh.retain2), showing what is in effect now. - Uninstaller: removes apt, Snap, Flatpak and AppImage apps with their leftovers. Reset keeps an app installed and moves its data to the Trash (for a Flatpak app its cache, config and data; for a snap its current revision and
common).
Removing old snap revisions makes systemd reload, which can bring Ubuntu’s routine “new update” notice; nothing is broken. For the rest of an Ubuntu machine, see Free up disk space on Ubuntu as a developer and Steam, Proton and shader cache. Download CleanMate.
On Ubuntu, what apt purge keeps and where the leftovers in ~/.config hide is in uninstall an app and remove its leftover config files.
FAQ
Is it safe to remove disabled snap revisions? Yes. You lose only the option to snap revert to them.
Why is /var/lib/snapd so big? Each revision is a full compressed image of the app. With 2 or 3 revisions of large snaps (Firefox, GNOME, CUDA, IDEs) it adds up fast.
Does flatpak uninstall –unused remove apps? No. Only runtimes and extensions that no installed app uses.
Can I set refresh.retain to 1? No, snapd accepts 2 to 20.
