How to unmount and possibly delete old Ubuntu Core snap

36,029

Solution 1

  sudo snap remove core --revision 122
  sudo snap remove core --revision 352

So, basically passing the revisions to remove in the command line.

To check the ones you've installed you have to use snap list [snap-name] --all

Solution 2

To completley remove snap core, snap and mounted filesystems:

  1. List installed snap cores snap list --all should give you something like:

    Name Version Rev Tracking Publisher Notes core 16-2.41 7713 stable canonical✓ core,disabled core 16-2.42 7917 stable canonical✓ core

  2. Remove disabled ones first snap remove core --revision 7713 notice the Rev column in step 1 should match --revision

  3. Uninstall snapd (on Ubuntu: apt-get purge snapd)

  4. Findout if snap is still mounted (for example df -H) gives something like
    /dev/loop0 94M 94M 0 100% /snap/core/7917 and unmount it umount /snap/core/7917 but it shouldn't

  5. If there are still mounted fs-es, you should attempt manual cleanup of /etc/systemd/system/snap-core-* something files.

Next time when your server reboots, snaps won't be there, unless you install/remove snapd again from some reason...

Solution 3

This is done, so you can snap revert to rollback to an older snap version.

Solution 4

So I unmount the old snap:

sudo umount /snap/ubuntu-core/122

and then done some manual clean up

sudo rmdir /snap/ubuntu-core/122
sudo rm /var/lib/snapd/snaps/ubuntu-core_122.snap

The same for the other one. The sky did not fall... yet

Share:
36,029

Related videos on Youtube

solsTiCe
Author by

solsTiCe

Updated on September 18, 2022

Comments

  • solsTiCe
    solsTiCe over 1 year

    When I type:

    $ mount|grep snap
    /var/lib/snapd/snaps/ubuntu-core_352.snap on /snap/ubuntu-core/352 type squashfs (ro,relatime)
    /var/lib/snapd/snaps/ubuntu-core_423.snap on /snap/ubuntu-core/423 type squashfs (ro,relatime)
    /var/lib/snapd/snaps/ubuntu-core_122.snap on /snap/ubuntu-core/122 type squashfs (ro,relatime)
    

    I see several old snap "mounted" and available while only the latest version is used as current in /snap/ubuntu-core

    It's not a big deal but do I need older ubuntu core ? Isn't this a bug there are not deleted ? Could I simply unmount and delete the files ?

  • dess
    dess about 7 years
    Considering current package name, up to date command looks like: sudo snap remove core --revision 122
  • Serge Stroobandt
    Serge Stroobandt over 6 years
    In my case, the last command sudo rm /var/lib/snapd/snaps/ubuntu-core_122.snap was non necessary.
  • Pablo Bianchi
    Pablo Bianchi over 5 years
    snap list --all to list installed packages with all revisions. Check also how to remove all disabled snap packages.
  • tsbertalan
    tsbertalan over 5 years
    gist.github.com/tsbertalan/f49f892a58d2a0889358e5b6b64af028 Here's a gist that automates this for multiple mounts. It doesn't actually run its commands; just prints what you would run, which is easy enough to change.
  • solsTiCe
    solsTiCe over 5 years
    yout script removes all the snaps. This is not what you want !
  • Rabbit
    Rabbit about 5 years
    sudo: unmount: command not found .... ?
  • tanius
    tanius over 3 years
    Perfect! Finally a way to remove snaps that snapd somehow forgot about and does not list in sudo snap list --all. Happened to me for the openscad-nightly snap for some reason.