Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  13] [ 0]  / answers: 1 / hits: 2631  / 2 Years ago, tue, may 31, 2022, 12:47:03

While examining the snap packages that are installed in a system, I noticed that some packages have a duplicate, one having an over revision number while the other having a newer revision number. For such duplicated packages, my questions are:



  1. Why are they duplicated?

  2. Can I remove the older package to ensure better disk space management?

  3. How do I remove the older package?


Below are examples of packages that do and do not have duplicates:


$ du -hcs /var/lib/snapd/snaps/*
31M /var/lib/snapd/snaps/2048x_3.snap
286M /var/lib/snapd/snaps/atom_282.snap
4.0K /var/lib/snapd/snaps/bare_5.snap
72M /var/lib/snapd/snaps/bitwarden_58.snap
72M /var/lib/snapd/snaps/bitwarden_59.snap
196M /var/lib/snapd/snaps/blender_1113.snap
214M /var/lib/snapd/snaps/blender_1237.snap
9.1M /var/lib/snapd/snaps/canonical-livepatch_119.snap
9.1M /var/lib/snapd/snaps/canonical-livepatch_126.snap
148M /var/lib/snapd/snaps/chromium_1854.snap
148M /var/lib/snapd/snaps/chromium_1864.snap
17M /var/lib/snapd/snaps/chromium-ffmpeg_23.snap
18M /var/lib/snapd/snaps/chromium-ffmpeg_24.snap
....

~$ ls -lh /var/lib/snapd/snaps/
total 12G
-rw------- 2 root root 31M Aug 5 06:23 2048x_3.snap
-rw------- 2 root root 286M Aug 5 08:35 atom_282.snap
-rw------- 2 root root 4.0K Sep 22 18:17 bare_5.snap
-rw------- 1 root root 72M Oct 30 00:20 bitwarden_58.snap
-rw------- 1 root root 72M Dec 9 04:28 bitwarden_59.snap
-rw------- 1 root root 196M Nov 18 04:06 blender_1113.snap
-rw------- 1 root root 214M Dec 4 09:39 blender_1237.snap
-rw------- 2 root root 9.1M Nov 17 21:06 canonical-livepatch_119.snap
-rw------- 2 root root 9.1M Nov 22 22:39 canonical-livepatch_126.snap
-rw------- 1 root root 148M Dec 16 04:28 chromium_1854.snap
-rw------- 1 root root 148M Jan 8 08:33 chromium_1864.snap
-rw------- 1 root root 17M Sep 3 06:29 chromium-ffmpeg_23.snap
-rw------- 2 root root 18M Nov 29 14:23 chromium-ffmpeg_24.snap
....

On the system that I am looking at, the total disk space utilized by /var/lib/snapd/snaps/* is 12,180.248 MB. The disk space of all the duplicated packages(i.e. older revision of the same package) is 4,163.1 MB. In short, the older revision packages currently takes up 34.18% of the 12,180.248 MB. This appears to be a cost to using SNAP apps that I had not realised before.


More From » 20.04

 Answers
4

To answer your questions:


Why are they duplicated?


⇢ They're different revisions (versions), not duplications.


Can I remove the older package to ensure better disk space management?


⇢ Yes. It's your computer, after all.


How do I remove the older package?


You can do this in Terminal like this:


snap remove {snap} --revision={revision}

You can also tell the system how many past versions to limit itself to like this:


sudo snap set system refresh.retain=2

Note: The value must be between 2 and 20, and a number like 2 or 3 is generally recommended to save storage space and allow a rollback in the event of a bad update.


If you would like to list all the snaps and their versions, you can run this command:


snap list --all

Which will give you something like:


Name                 Version                     Rev    Tracking         Publisher   Notes
bare 1.0 5 latest/stable canonical✓ base
canonical-livepatch 10.0.1 119 latest/stable canonical✓ disabled
canonical-livepatch 10.1.2 126 latest/stable canonical✓ -
core 16-2.52 11798 latest/stable canonical✓ core,disabled
core 16-2.52.1 11993 latest/stable canonical✓ core
core18 20211028 2253 latest/stable canonical✓ base
core18 20211015 2246 latest/stable canonical✓ base,disabled
core20 20211115 1242 latest/stable canonical✓ base,disabled
core20 20211129 1270 latest/stable canonical✓ base
gnome-3-28-1804 3.28.0-19-g98f9e67.98f9e67 145 latest/stable canonical✓ disabled
gnome-3-28-1804 3.28.0-19-g98f9e67.98f9e67 161 latest/stable canonical✓ -
gnome-3-34-1804 0+git.3556cb3 77 latest/stable/… canonical✓ -
gnome-3-34-1804 0+git.3556cb3 72 latest/stable/… canonical✓ disabled
gnome-3-38-2004 0+git.cd626d1 87 latest/stable canonical✓ -
gnome-3-38-2004 0+git.6ba6040 76 latest/stable canonical✓ disabled
gtk-common-themes 0.1-52-gb92ac40 1515 latest/stable/… canonical✓ disabled
gtk-common-themes 0.1-59-g7bca6ae 1519 latest/stable/… canonical✓ -
snap-store 3.38.0-66-gbd5b8f7 558 latest/stable/… canonical✓ -
snap-store 3.38.0-64-g23c4c77 547 latest/stable/… canonical✓ disabled
snapd 2.53.2 14066 latest/stable canonical✓ snapd,disabled
snapd 2.53.4 14295 latest/stable canonical✓ snapd



Need a Script?


IMPORTANT: You will want to check the output of snap list --all on your computer before continuing, and the following is a script that should not be copy/pasted without sanity checking if you are using a locale that is not en_US.UTF-8.


The Script:


#!/bin/bash
# This script will remove disabled snap revisions.
set -eu

LANG=C snap list --all | awk '/disabled/{print $1, $3}' |
while read name rev; do
snap remove "$name" --revision="$rev"
done

This will run snap list -all and extract the lines that contain the word disabled. This will be different depending on your locale, so check the output of the function first, then update awk '/disabled/ to replace disabled with the label that is found in your output.


Save the script to a file (for example scrub-snaps.sh) and then set it as being executable:


sudo chmod +x scrub-snaps.sh

Now you can run it, remembering to use sudo:


sudo ./scrub-snaps.sh

Note: sudo was not part of the script, but can be added if you prefer to have it in there. Either way, you'll be prompted for a password if required.


[#867] Tuesday, May 31, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tiowift

Total Points: 119
Total Questions: 113
Total Answers: 110

Location: South Sudan
Member since Sun, Jul 11, 2021
3 Years ago
tiowift questions
Wed, Aug 3, 22, 04:45, 2 Years ago
Mon, Nov 7, 22, 10:58, 2 Years ago
Wed, May 10, 23, 17:52, 1 Year ago
;