/var/lib/snapd/snaps/ is not cleaned up

I’m running ubuntu 20.04 and recently discovered that /var/lib/snapd/snaps/ contains a lot of quite old snaps that I expect to be cleaned up.

For instance skype:

# ls -la /var/lib/snapd/snaps/skype_*
-rw------- 1 root root 146771968 Apr 19  2023 /var/lib/snapd/snaps/skype_266.snap
-rw------- 1 root root 146771968 Apr 24  2023 /var/lib/snapd/snaps/skype_267.snap
-rw------- 1 root root 147140608 Apr 25  2023 /var/lib/snapd/snaps/skype_269.snap
-rw------- 1 root root 147746816 May 24  2023 /var/lib/snapd/snaps/skype_274.snap
-rw------- 1 root root 148983808 Jun 16  2023 /var/lib/snapd/snaps/skype_280.snap
-rw------- 1 root root 189390848 Aug 17 12:56 /var/lib/snapd/snaps/skype_291.snap
-rw------- 1 root root 183963648 Oct  2 20:54 /var/lib/snapd/snaps/skype_301.snap
-rw------- 1 root root 183963648 Oct  6 22:56 /var/lib/snapd/snaps/skype_302.snap
-rw------- 1 root root 184414208 Nov  1 20:45 /var/lib/snapd/snaps/skype_306.snap
-rw------- 1 root root 184659968 Dec  5 23:00 /var/lib/snapd/snaps/skype_314.snap
-rw------- 1 root root 185167872 Dec  8 18:47 /var/lib/snapd/snaps/skype_317.snap
-rw------- 1 root root 185163776 Dec 11 22:19 /var/lib/snapd/snaps/skype_318.snap
-rw------- 1 root root 185167872 Dec 14 11:36 /var/lib/snapd/snaps/skype_320.snap
-rw------- 1 root root 185294848 Jan 23 22:58 /var/lib/snapd/snaps/skype_323.snap
-rw------- 1 root root 187752448 Jan 31 19:28 /var/lib/snapd/snaps/skype_325.snap
-rw------- 1 root root 187752448 Feb  5 16:23 /var/lib/snapd/snaps/skype_326.snap

yet only 2 versions are actually installed:

# snap list --all|grep -i skype
skype              8.111.0.607                 323    latest/stable    skype**         -
skype              8.110.0.218                 320    latest/stable    skype**         disabled

But even here there is some oddity - see that the installed are 320 and 323, but also 325 and 326 are in the snaps :shrug:

I wouldn’t bother otherwise, but currently /var/lib/snapd/snaps/ already takes 15Gb and over the time it will only grow more.

This machine is rebooted regularly (usually every kernel release, so at least once or twice a month), so it definitely is not that some cleanup routine that didn’t have chance to trigger the actual cleanup.

Am I doing something wrong and should I somehow clean it up manually? Or is it some well known bug, which I honestly couldn’t find.

PS: this question is the exact copy from my original post at askubuntu.com

1 Like

this thread may be of interest to you

Not sure if there is any official bug report of this yet

1 Like

Hi @zerkms .

To remove the unnecessary data, I recommend you to follow this guide https://snapcraft.io/docs/snapshots.

See:

1 Like

I don’t have any snapshots created:

➜ snap saved                         
No snapshots found.

@mrk @ogra as there is no known bug report created and I couldn’t find any myself - here I created new: Bug #2052666 “/var/lib/snapd/snaps/ is not cleaned up” : Bugs : snapd

2 Likes

@zerkms , precede the above command by sudo to see .

I did check it with sudo initially too, sorry I didn’t mention it:

➜ sudo snap saved
No snapshots found.

And there is only one user (me) on this laptop.

According the output of the command ls -la /var/lib/snapd/snaps/skype_*, the root have the right to write on thes files. Normally, you can remove them if you are a super user .

Well, yes and no :slight_smile:

I expect software to maintain its own storage. And it’s not immediately obvious if messing with filesystem structure would not corrupt some snapd index (as I’m not aware how exactly snapd manages those directories and handles their absence). So in general I expect to NOT remove anything by myself unless I know it’s 100% safe :person_shrugging:

1 Like

If you execute the same command with in more -t option, the output will be in order from newest to oldest .

Like :

ls -atl *.snap

Otherwise, you can remove the skype snap, then remove the files in questions.

You can then install skype again .