55

I just realized, after using gnome-disk-utility (3.18.3.1), that my 16.04 installation features several small loop devices.

In detail:

  • 78 MB Loop Device (/var/lib/snapd/sn_ntu-core_352.snap -> /dev/loop0)
  • 76 MB Loop Device (/var/lib/snapd/sn_ntu-core_216.snap -> /dev/loop1)
  • 79 MB Loop Device (/var/lib/snapd/sn_ntu-core_423.snap -> /dev/loop2)
  • 705 KB Loop Device (/var/lib/snapd/snaps/tpad_12.snap -> /dev/loop3)
  • 684 KB Loop Device (/var/lib/snapd/snaps/tpad_11.snap -> /dev/loop5)
  • 705 KB Loop Device (/var/lib/snapd/snaps/tpad_13.snap -> /dev/loop6)

Image showing gnome-disk-utility

screenshot of gnome-disk-utility UI

My questions are as follows:

  • What are those loop devices used for?
  • Is that an expected behaviour in 16.04?
  • Can I remove them? And if so - how? just by unmounting?
  • Is there any risk in removing the 2 installed snaps mentioned below (tpad and ubuntu-core)?

UPDATE

Installed snaps

According to snap list I do have

  • tpad (1.8.1)
  • ubuntu-core (16.04.1)

installed. I remember I did tinker with snaps for a short time when I realized this option - but am pretty unsure if I installed those 2 snaps - or if they are pre-/auto-installed.

tpad is a Terminal text editor with GUI-like user interface I did install manually, as I don't use it I removed it now via sudo snap remove tpad. As a result the 2 loop devices pointing to tpad are gone in gnome-disk-utility.

So - at the current point I am still having 1 snap installed called ubuntu-core and I don't know what it is used for. The summary of this particular snap is

The ubuntu-core OS snap
4
  • This might be a bug
    – d a i s y
    Feb 6, 2017 at 6:20
  • 2
    This might be this bug. Snapd left all those ugly loop devices. Also there at every df. Apr 8, 2017 at 20:23
  • @PabloBianchi Are they taking up actual HD space? Even if I unnstall the snap package?
    – a06e
    May 30, 2017 at 20:50
  • @PabloBianchi That bug is marked as WONTFIX. Too bad, since it's very tacky (Neglected and in a state of disrepair). Mar 27, 2019 at 18:01

4 Answers 4

28

Each individual snap is a read-only squashfs filesystem image. In order to access files within these images, snapd mounts the images, one for each installed snap version, inside /snap.

This list of mounted loop devices thus effectively includes the snaps you have installed, and is part of the normal operation of snapd. You should not attempt remove them. If you really don't want them there at all, then you can remove the corresponding snaps.

Various utilities are designed to show you all mounted filesystems, including loopback ones, which is why you see them. snapd is the first common daemon I've seen to maintain a large and variable set of loopback mounts in this way, which admittedly does hamper the UI of these utilities. Perhaps eventually we'll see these utilities hide loopback mounts by default.

8

You can remove old core by execute

sudo snap remove core --revision <number>

manually.

3
  • This wouldn't solve the problem in this case, sorry!
    – Ads20000
    Jan 3, 2018 at 1:48
  • How to list the labels <number>? The df "/dev/loop2" is number 2? Aug 9, 2019 at 20:43
  • What worked for me was to remove the snap cache that had grown a lot over time. This led to removal of all the unnecessary loop devices. Command to remove snap cache is sudo apt purge snapd More information can be found here - unix.stackexchange.com/questions/590319/…
    – pyronic
    Aug 28, 2022 at 21:37
5

If you don't use snaps it than just uninstall them as you did. Ubuntu core is the snap that the others snaps need to run. Visiblity of snaps in gnome-disk-utility is probably not wanted but it's a side effect of how snaps are working.

2
  • 6
    The snap ubuntu-core is not removeable using sudo snap remove ubuntu-core -> error: cannot remove "ubuntu-core": snap "ubuntu-core" is not removable. I removed snapd package as i am not going to use snap further, but the 3 snap loop devices in disk-utility are still remaining.
    – dufte
    Oct 10, 2016 at 6:22
  • The above may have been a bug that is now fixed: I just removed snapd from a fresh install of Ubuntu 19.04 (server) and the core snap was removed as a side-effect.
    – zwol
    Jul 17, 2019 at 15:08
1

Two ways using a script:

The best and simple:

sudo fdisk -l | sed -e '/ \/dev\/loop/,+5d'

And the funny geek way (for study of sed, IFS, etc) :

# Copies output to var x: 
x=`sudo fdisk -l`

# Tranform new lines in @@@
y=`sed ':a;N;s/\n/@@@/g' <<< "$x"`

# Inform linux the new separator
IFS='@@@'

for a in $y
  do
  if [[  "$a" == *"/dev/sd"* ]]; then
    echo -e "$a"
  fi
  done
# Just do add a line separator above:
echo ''

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .