How do I manage how many revisions snapd keeps of an application?

5,122

Solution 1

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.

Solution 2

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.

Solution 3

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:~$

Share:
5,122

Related videos on Youtube

Stanley Mitchell
Author by

Stanley Mitchell

Updated on September 18, 2022

Comments

  • Stanley Mitchell
    Stanley Mitchell almost 2 years

    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?

  • fIwJlxSzApHEZIl
    fIwJlxSzApHEZIl almost 4 years
    This superuser answer was extremely helpful to purge all older snap versions: superuser.com/questions/1310825/…