/dev/loopX devices left around for removed snap revisions

Bug #1841137 reported by Alberto Donato on 2019-08-23
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
snapd
High
Zygmunt Krynicki

Bug Description

On my 19.04 box, I noticed the Gnome file manager at times starts showing extra drivers, if I click on those they get mounted and they turn out to be snaps filesystems.

Looking at gnome VFS mounts I see:

$ gio mount -li
Drive(0): SanDisk SD8TB8U512G1001
  Type: GProxyDrive (GProxyVolumeMonitorUDisks2)
  ids:
   unix-device: '/dev/sda'
  themed icons: [drive-harddisk-solidstate] [drive-harddisk] [drive] [drive-harddisk-solidstate-symbolic] [drive-harddisk-symbolic] [drive-symbolic]
  symbolic themed icons: [drive-harddisk-solidstate-symbolic] [drive-harddisk-symbolic] [drive-symbolic] [drive-harddisk-solidstate] [drive-harddisk] [drive]
  is_removable=0
  is_media_removable=0
  has_media=1
  is_media_check_automatic=1
  can_poll_for_media=0
  can_eject=0
  can_start=0
  can_stop=0
  start_stop_type=shutdown
  sort_key=00coldplug/00fixed/sd____a
Volume(0): 57 MB Volume
  Type: GProxyVolume (GProxyVolumeMonitorUDisks2)
  ids:
   class: 'loop'
   unix-device: '/dev/loop47'
  themed icons: [drive-removable-media] [drive-removable] [drive] [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic]
  symbolic themed icons: [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic] [drive-removable-media] [drive-removable] [drive]
  can_mount=1
  can_eject=0
  should_automount=0
  sort_key=gvfs.time_detected_usec.1565684753456472
Volume(1): 57 MB Volume
  Type: GProxyVolume (GProxyVolumeMonitorUDisks2)
  ids:
   class: 'loop'
   unix-device: '/dev/loop8'
  themed icons: [drive-removable-media] [drive-removable] [drive] [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic]
  symbolic themed icons: [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic] [drive-removable-media] [drive-removable] [drive]
  can_mount=1
  can_eject=0
  should_automount=0
  sort_key=gvfs.time_detected_usec.1565864986223896
Volume(2): 57 MB Volume
  Type: GProxyVolume (GProxyVolumeMonitorUDisks2)
  ids:
   class: 'loop'
   unix-device: '/dev/loop9'
  themed icons: [drive-removable-media] [drive-removable] [drive] [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic]
  symbolic themed icons: [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic] [drive-removable-media] [drive-removable] [drive]
  can_mount=1
  can_eject=0
  should_automount=0
  sort_key=gvfs.time_detected_usec.1565956723163136
Volume(3): 57 MB Volume
  Type: GProxyVolume (GProxyVolumeMonitorUDisks2)
  ids:
   class: 'loop'
   unix-device: '/dev/loop51'
  themed icons: [drive-removable-media] [drive-removable] [drive] [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic]
  symbolic themed icons: [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic] [drive-removable-media] [drive-removable] [drive]
  can_mount=1
  can_eject=0
  should_automount=0
  sort_key=gvfs.time_detected_usec.1566122858757365
Volume(4): 57 MB Volume
  Type: GProxyVolume (GProxyVolumeMonitorUDisks2)
  ids:
   class: 'loop'
   unix-device: '/dev/loop3'
  themed icons: [drive-removable-media] [drive-removable] [drive] [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic]
  symbolic themed icons: [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic] [drive-removable-media] [drive-removable] [drive]
  can_mount=1
  can_eject=0
  should_automount=0
  sort_key=gvfs.time_detected_usec.1566224621352304
Volume(5): 99 MB Volume
  Type: GProxyVolume (GProxyVolumeMonitorUDisks2)
  ids:
   class: 'loop'
   unix-device: '/dev/loop14'
  themed icons: [drive-removable-media] [drive-removable] [drive] [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic]
  symbolic themed icons: [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic] [drive-removable-media] [drive-removable] [drive]
  can_mount=1
  can_eject=0
  should_automount=0
  sort_key=gvfs.time_detected_usec.1566324204041632
Volume(6): 57 MB Volume
  Type: GProxyVolume (GProxyVolumeMonitorUDisks2)
  ids:
   class: 'loop'
   unix-device: '/dev/loop60'
  themed icons: [drive-removable-media] [drive-removable] [drive] [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic]
  symbolic themed icons: [drive-removable-media-symbolic] [drive-removable-symbolic] [drive-symbolic] [drive-removable-media] [drive-removable] [drive]
  can_mount=1
  can_eject=0
  should_automount=0
  sort_key=gvfs.time_detected_usec.1566499678555259

Those loop devices correspond to old snap revisions that have been removed (by snapd itself), but it seems the loopback devices are left around:

$ losetup -l | grep deleted
/dev/loop47 0 0 1 1 /var/lib/snapd/snaps/lxd_11353.snap (deleted) 0 512
/dev/loop8 0 0 1 1 /var/lib/snapd/snaps/lxd_11437.snap (deleted) 0 512
/dev/loop51 0 0 1 1 /var/lib/snapd/snaps/lxd_11633.snap (deleted) 0 512
/dev/loop9 0 0 1 1 /var/lib/snapd/snaps/lxd_11595.snap (deleted) 0 512
/dev/loop14 0 0 1 1 /var/lib/snapd/snaps/telegram-desktop_836.snap (deleted) 0 512
/dev/loop60 0 0 1 1 /var/lib/snapd/snaps/lxd_11672.snap (deleted) 0 512
/dev/loop3 0 0 1 1 /var/lib/snapd/snaps/lxd_11643.snap (deleted) 0 512

Note that those snap files don't exist anymore under /var/lib/snapd/snaps.

A reboot fixes the issue, but it starts appearing again at the next udpate of a snap.

Snapd versions are the following:

$ snap version
snap 2.40+19.04
snapd 2.40+19.04
series 16
ubuntu 19.04
kernel 5.0.0-21-generic

ii snapd 2.40+19.04 amd64 Daemon and tooling that enable snap packages

Alberto Donato (ack) wrote :

FTR, "losetup -d" on those loop devices doesn't seem to work

Alberto Donato (ack) wrote :

As a further test, I tried removing the telegram-desktop snap entirely, now all past revisions are stuck as "deleted":

$ losetup | grep deleted
/dev/loop47 0 0 1 1 /var/lib/snapd/snaps/lxd_11353.snap (deleted) 0 512
/dev/loop8 0 0 1 1 /var/lib/snapd/snaps/lxd_11437.snap (deleted) 0 512
/dev/loop63 0 0 1 1 /var/lib/snapd/snaps/telegram-desktop_877.snap (deleted) 0 512
/dev/loop51 0 0 1 1 /var/lib/snapd/snaps/lxd_11633.snap (deleted) 0 512
/dev/loop38 0 0 1 1 /var/lib/snapd/snaps/telegram-desktop_891.snap (deleted) 0 512
/dev/loop9 0 0 1 1 /var/lib/snapd/snaps/lxd_11595.snap (deleted) 0 512
/dev/loop14 0 0 1 1 /var/lib/snapd/snaps/telegram-desktop_836.snap (deleted) 0 512
/dev/loop60 0 0 1 1 /var/lib/snapd/snaps/lxd_11672.snap (deleted) 0 512
/dev/loop3 0 0 1 1 /var/lib/snapd/snaps/lxd_11643.snap (deleted) 0 512

Paweł Stołowski (stolowski) wrote :

That's interesting; I had one such loop device (for an old revision of core that was no longer present in the system) on my 18.04 test box. I played a bit with this on 19.04, installed and removed a bunch of snaps, but couldn't reproduce the problem with snapd 2.40 on 19.04, apparently there are some factors that make it happen over longer periods of time.

Changed in snapd:
status: New → Triaged
Zygmunt Krynicki (zyga) wrote :

ack: are you seeing any leftover LXD processes or leftover telegram processes?

Changed in snapd:
status: Triaged → Confirmed
Zygmunt Krynicki (zyga) wrote :

I'm assigning this to myself. There are identical issues detected by my mount leak detector while debugging the snapd test suite. I just chatted with other snapd developers and some of them were affected as well. I will write a quick test and see what I find.

Changed in snapd:
assignee: nobody → Zygmunt Krynicki (zyga)
importance: Undecided → High
Alberto Donato (ack) wrote :

zyga: no, there are no leftover processes.

If it matters, I'm probably seeing this a lot on my laptop since I always suspend and rarely reboot.
Yesterday before rebooting I had about 10 leftover loop mounts.

Zygmunt Krynicki (zyga) wrote :

Yes, this is certainly a factor. Rebooting will automatically clear those out. We're working through theories that could explain how we leak those now. I'll update the bug as we learn more.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers