15

So I installed vlc daily built snap package.

It's working great, no problems there. However I noticed that after upgrade the system has 2 versions of vlc (7 and 9). That can be seen when browsing /snap/vlc/ directory and using system monitor.

This is also the case with other snaps. Is there a way to automatically delete older versions of snaps? Or do I just delete them using plain "rm" command? Is it safe to delete them that way?

0

3 Answers 3

20

For Ubuntu 20.04 and newer, snapd will automatically retain two revisions (usually current plus one older) by default, and will delete older.

For Ubuntu 18.04 and earlier, snapd will automatically retain three revisions (usually current plus two older) by default, and will delete older.

In mid-2018, snapd was updated so that the number of revisions is configurable (though never less than 2).

Use the command:

snap set system refresh.retain=N

N cannot be less than two.

3
  • 2
    This superuser answer was extremely helpful to purge all older snap versions: superuser.com/questions/1310825/… Jul 1, 2020 at 15:43
  • Why can't we set it to be 1?
    – nog642
    Apr 26, 2023 at 20:29
  • @nog it's fundamental to the way snap packages work. Older version(s) retained in case the newer is broken.
    – user535733
    Apr 26, 2023 at 20:43
5

In speaking with Ubuntu developers, the current default is to keep three prior versions of a snap so that you can roll-back to a prior version if needed. This default setting is not configurable.

You can use the command snap remove --revision=<an old one> snapname to remove an older revision of a snap.

They are considering whether to have only the current snap mounted as a loop filesystem, but I don't know the status of that.

2

Answer from doug, somewhat extended:

/snap/* is read-only and snaps are mounted there. The reason for this is that snapd allows you to roll back to an older version of a given snap, that's why it keeps multiple versions. Calling snap remove will remove them all from the system again. There is a r/w location for snaps, but that's unrelated. https://developer.ubuntu.com/en/snappy/guides/garbage needs an update, but it explains the general concept.

Rolling back is done using snap revert:

daniel@daydream:~$ snap revert --help Usage: snap [OPTIONS] revert []

The revert command reverts the given snap to its state before the latest refresh. This will reactivate the previous snap revision, and will use the original data that was associated with that revision, discarding any data changes that were done by the latest revision. As an exception, data which the snap explicitly chooses to share across revisions is not touched by the revert process.

Application Options: --version print the version and exit

Help Options: -h, --help Show this help message daniel@daydream:~$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .