In October 2015, Ubuntu 15.10 was shipped with something called snappy
, which is the "software deployment and package management system developed by Canonical" (copy/paste from Wikipedia).
By now, most of Ubuntu users are not aware of snaps until they run a df -h
and they see something like:
/dev/loop1 174M 174M 0 100% /snap/spotify/34
/dev/loop4 55M 55M 0 100% /snap/core18/1049
/dev/loop3 141M 141M 0 100% /snap/gnome-3-26-1604/88
/dev/loop5 4.2M 4.2M 0 100% /snap/gnome-calculator/406
/dev/loop7 89M 89M 0 100% /snap/core/7270
/dev/loop8 2.8M 2.8M 0 100% /snap/telegram-cli/25
/dev/loop9 1.0M 1.0M 0 100% /snap/gnome-logs/61
/dev/loop10 36M 36M 0 100% /snap/gtk-common-themes/1198
/dev/loop11 436M 436M 0 100% /snap/libreoffice/133
/dev/loop12 150M 150M 0 100% /snap/gnome-3-28-1804/63
/dev/loop13 89M 89M 0 100% /snap/core/7169
/dev/loop14 57M 57M 0 100% /snap/snapcraft/3059
/dev/loop15 15M 15M 0 100% /snap/gnome-characters/292
/dev/loop16 181M 181M 0 100% /snap/spotify/35
/dev/loop17 3.8M 3.8M 0 100% /snap/gnome-system-monitor/95
/dev/loop20 141M 141M 0 100% /snap/gnome-3-26-1604/90
/dev/loop21 419M 419M 0 100% /snap/libreoffice/134
/dev/loop2 3.8M 3.8M 0 100% /snap/gnome-system-monitor/100
/dev/loop22 15M 15M 0 100% /snap/gnome-characters/296
/dev/loop23 150M 150M 0 100% /snap/gnome-3-28-1804/67
/dev/loop24 43M 43M 0 100% /snap/gtk-common-themes/1313
/dev/loop0 55M 55M 0 100% /snap/core18/1055
The thing is, when an snap is installed the previous version is not uninstalled or removed, and you manually need to do that. Also, keep in mind that "updates" are, in fact, the install of a new version... So by doing the math, in a few months your df -h
will be a mess.
To identify with more detail snaps installed in my computer, the best option is:
$ snap list --all
Name Version Rev Tracking Publisher Notes
core 16-2.39.3 7270 stable canonical✓ core
core 16-2.39.2 7169 stable canonical✓ core,disabled
core18 20190627 1049 stable canonical✓ base,disabled
core18 20190704 1055 stable canonical✓ base
gnome-3-26-1604 3.26.0.20190705 90 stable/… canonical✓ -
gnome-3-26-1604 3.26.0.20190621 88 stable/… canonical✓ disabled
gnome-3-28-1804 3.28.0-10-gaa70833.aa70833 67 stable canonical✓ -
gnome-3-28-1804 3.28.0-10-gaa70833.aa70833 63 stable canonical✓ disabled
gnome-calculator 3.32.1 406 stable/… canonical✓ -
gnome-characters v3.32.1+git2.3367201 292 stable/… canonical✓ disabled
gnome-characters v3.32.1+git2.3367201 296 stable/… canonical✓ -
gnome-logs 3.32.0-4-ge8f3f37ca8 61 stable/… canonical✓ -
gnome-system-monitor 3.32.1-2-ga7c19eaeff 95 stable/… canonical✓ disabled
gnome-system-monitor 3.32.1-3-g0ea89b4922 100 stable/… canonical✓ -
gtk-common-themes 0.1-16-g2287c87 1198 stable/… canonical✓ disabled
gtk-common-themes 0.1-22-gab0a26b 1313 stable/… canonical✓ -
libreoffice 6.2.5.2 134 stable canonical✓ -
libreoffice 6.2.5.2 133 stable canonical✓ disabled
snapcraft 3.6 3059 stable canonical✓ classic
spotify 1.1.5.153.gf614956d-16 35 stable spotify✓ -
spotify 1.1.0.237.g378f6f25-11 34 stable spotify✓ disabled
telegram-cli 1.4.5 25 stable marius-quabeck -
And here's something interesting: The Notes column. Maybe we can use that column to filter and remove unused or disabled snaps? Yes, we can! And I do it with the following script:
#!/bin/bash
set -eu
snap list --all | awk '/disabled/{print $1, $3}' |
while read s r; do
sudo snap remove "$s" --revision="$r"
done
As usual, I hope it helps :)
Top comments (4)
Hi Boris, thanks for this great tip, once you have executed the batch how long should it take before taking effect ?
Hi mohbra,
It really depends on how many snaps you have. This is the time it took me to remove 13 old snaps a few minutes ago:
clean-snap 0.54s user 0.59s system 7% cpu 15.392 total
It’s weird when I ran the command to view the list it sort of hanged on me. So cancel the request created the batch and run it. It’s still going on. The thing is I have executed the batch from ssh. Any advice on what I can do next
It’s been over an hour now.