Ubuntu – Why are there multiple loop devices for the same snap

16.04loop-devicemountsnap

I used lsblk to check connected devices, when I found that there are a total of 3 loop devices for the same snap "core", with revision numbers.

loop1    7:1    0  81.6M  1 loop /snap/core/4110
loop2    7:2    0  81.7M  1 loop /snap/core/4017
loop0    7:0    0  81.3M  1 loop /snap/core/3887

On checking the mount directory of snaps, this is what I get:

drwxr-xr-x 24 root root 321 Jan 22 13:17 3887
drwxr-xr-x 24 root root 321 Feb  6 20:48 4017
drwxr-xr-x 24 root root 321 Feb 20 22:37 4110
lrwxrwxrwx  1 root root   4 Feb 23 19:31 current -> 4110

and snap list shows this:

core  16-2.31.1  4110  canonical  core

Why is snapd not removing the old versions of snap core? Is it a normal behavior, or is there any way to remove this if this is not supposed to happen? I'm using Ubuntu 16.04.

Best Answer

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.