CleanMate

All guides · Ubuntu · Updated

Snap and Flatpak eating disk space on Ubuntu: old snap revisions, unused Flatpak runtimes, app caches

Why snap and Flatpak grow on Ubuntu and the safe commands to shrink them: snap list --all and disabled revisions, snap remove --revision, refresh.retain, flatpak uninstall --unused, flatpak repair and the caches in ~/snap and ~/.var/app.

Install on Ubuntu — free and open source

CleanMate for Ubuntu after a scan, listing old snap revisions and app caches with sizes

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

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):

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.

Looking for a BleachBit alternative for Ubuntu? See how CleanMate compares, feature by feature.

Skip the commands

Open source — star it on GitHub: CleanMate for Ubuntu

How CleanMate decides what is safe to remove →