2

I am using snapcraft & snap in a virtual-box. I gave it a 15GB image size but it ended up full quickly.

After verifying with a disk space analyzer, found that most of the space took by snaps packages. I removed some which I don't need like gnome-3-26 & gnome-3-28 core extensions.

But as you can see in the listing below, snap preserves previous release of each package as backup.

I am using this vbox just for testing. I want to make snap act like apt so it keeps only current release. I don't want to worry about cleaning it manually.

How to make snap auto-remove older package releases?

# snap list --all
Name                  Version                Rev    Tracking         Publisher   Notes
core                  16-2.44.3              9066   latest/stable    canonical*  core
core                  16-2.44.1              8935   latest/stable    canonical*  core,disabled
core18                20200427               1754   latest/stable    canonical*  base
core18                20200311               1705   latest/stable    canonical*  base,disabled
gnome-3-34-1804       0+git.2c86692          27     latest/stable    canonical*  -
gnome-calculator      3.34.1+git4.c387feb0   704    latest/stable/…  canonical*  disabled
gnome-calculator      3.36.0+git4.51b0dc05   730    latest/stable/…  canonical*  -
gnome-characters      v3.32.1+git2.3367201   367    latest/stable/…  canonical*  disabled
gnome-characters      v3.32.1+git4.e06f0b2   495    latest/stable/…  canonical*  -
gnome-logs            3.34.0                 93     latest/stable/…  canonical*  -
gnome-logs            3.34.0                 81     latest/stable/…  canonical*  disabled
gnome-system-monitor  3.32.1-3-g0ea89b4922   111    latest/stable/…  canonical*  disabled
gnome-system-monitor  3.32.0-27-g32ed970e06  135    latest/stable/…  canonical*  -
gtk-common-themes     0.1-36-gc75f853        1506   latest/stable    canonical*  -
gtk-common-themes     0.1-30-gd41a42a        1502   latest/stable    canonical*  disabled
lxd                   4.0.1                  14804  latest/stable    canonical*  disabled
lxd                   4.0.1                  14890  latest/stable    canonical*  -
multipass             1.2.0                  2006   latest/stable    canonical*  classic
multipass             1.1.0                  1784   latest/stable    canonical*  disabled,classic
my-snap-name          0.1                    x13    -                -           disabled
my-snap-name          0.1                    x14    -                -           -
snapcraft             3.11                   4282   latest/stable    canonical*  classic
snappy-debug          0.36-snapd2.44+git     464    latest/stable    canonical*  -
user.dz
  • 48,105
  • 1
    Take a look here for refresh.retain, seems we have to keep at least 2 versions. Maybe it helps to empty the cache (sudo rm /var/lib/snapd/cache/*). The snaps gnome-3-26 & gnome-3-28 have been completely removed, I don't see them in your list. – mook765 May 02 '20 at 07:56
  • Thank you @mook765 , I see it doesn't allow less. I removed the cache as you mentioned and got me some space. Also found some snaps in /var/lib/snapd/seed witch contain some old snaps, seems those coming with CD fresh installation. Yes, I removed older gnome extensions completely after installing gnome-3-34. – user.dz May 02 '20 at 08:48

1 Answers1

0

Well, its setting refresh.retain does not allow less than 2.

A workaround using script:

snap list --all | while read snapname ver rev trk pub notes; do if [[ $notes = *disabled* ]]; then snap remove "$snapname" --revision="$rev"; fi; done

Source: Similar question on SU - How to remove old version of installed snaps?

user.dz
  • 48,105