Dangling snaps

Hi all,

I’m on OpenSUSE Tumbleweed and a while back I had to do some recovery and I suspect my /var/lib/snapd/state.json may have gotten corrupted at that time. Anyway, the effect is that I have some snaps in the system that snapd doesn’t know about. I’ve since re-installed some snaps but not all so I have for example:

  • 6 versions of atom, where snap list --all only shows 3
  • 6 versions of core snap, where snap list --all only shows 3
  • 3 versions of qownnotes snap, where snap list --all shows none

By X versions of a snap I mean the .snap file in /var/lib/snapd/snaps/ and them being mounted on /snap/$NAME/$VERSION.

My question is how to clean this up?
Can I just umount /snap/$NAME/$VERSION and rm /var/lib/snapd/snaps/$NAME_$VERSION.snap?
How do they get mounted automatically?
Any other files I would potentially need to remove?

Likely a systemd mount unit was left over. On openSUSE those will be named snap.<snap>.<revision>.mount. You can systemctl stop the units, remove them and remove the corresponding files under /var/lib/snapd/snap/.

Revision specific data, if present:

  • /var/snap/<snap>/<revision>
  • $HOME/snap/<snap>/<revision>

Double check you’re removing directories/mounts for revisions/snaps that are not tracked by snapd.