How to remove /dev/loops [duplicate]

On my Ubuntu desktop, the command fdisk -l shows /dev/loopX up to /dev/loop23. I'm using gnome-fallback on Ubuntu 18.04 LTS.

I'm wondering what possible effects these could have on performance and stabilty of the OS, and if they are just superfluous, how can I remove them?

root@pc5:~# fdisk -l
...
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop15: 3.7 MiB, 3821568 bytes, 7464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop16: 54.6 MiB, 57274368 bytes, 111864 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop17: 140.7 MiB, 147501056 bytes, 288088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop18: 14.8 MiB, 15462400 bytes, 30200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop19: 42.8 MiB, 44879872 bytes, 87656 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop20: 54.5 MiB, 57151488 bytes, 111624 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop21: 4.2 MiB, 4403200 bytes, 8600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop22: 153.5 MiB, 160935936 bytes, 314328 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop23: 140.7 MiB, 147501056 bytes, 288088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

output of df:

Filesystem      1K-blocks       Used  Available Use% Mounted on
udev              8128184          0    8128184   0% /dev
tmpfs             1630464       3716    1626748   1% /run
/dev/sda2       229184876   63255488  154217748  30% /
tmpfs             8152300     142672    8009628   2% /dev/shm
tmpfs                5120          4       5116   1% /run/lock
tmpfs             8152300          0    8152300   0% /sys/fs/cgroup
/dev/loop2         160512     160512          0 100% /snap/gnome-3-28-1804/110
/dev/loop3           4352       4352          0 100% /snap/gnome-calculator/544
/dev/loop0           3840       3840          0 100% /snap/gnome-system-monitor/111
/dev/loop4          91264      91264          0 100% /snap/core/8039
/dev/loop1           1024       1024          0 100% /snap/gnome-logs/81
/dev/loop6          87936      87936          0 100% /snap/shotcut/55
/dev/loop5         406528     406528          0 100% /snap/redis-desktop-manager/332
/dev/loop8          91264      91264          0 100% /snap/core/8213
/dev/loop7         406656     406656          0 100% /snap/redis-desktop-manager/335
/dev/loop9          15104      15104          0 100% /snap/gnome-characters/367
/dev/loop11        157184     157184          0 100% /snap/chromium/949
/dev/loop12         87808      87808          0 100% /snap/shotcut/53
/dev/loop13          1024       1024          0 100% /snap/gnome-logs/73
/dev/loop14         45312      45312          0 100% /snap/gtk-common-themes/1353
/dev/loop16         55936      55936          0 100% /snap/core18/1279
/dev/loop15          3840       3840          0 100% /snap/gnome-system-monitor/107
/dev/loop10        159872     159872          0 100% /snap/gnome-3-28-1804/91
/dev/loop17        144128     144128          0 100% /snap/gnome-3-26-1604/97
/dev/sda1          523248       6232     517016   2% /boot/efi
/dev/loop18         15104      15104          0 100% /snap/gnome-characters/359
/dev/loop19         43904      43904          0 100% /snap/gtk-common-themes/1313
/dev/loop20         55936      55936          0 100% /snap/core18/1265
/dev/loop21          4352       4352          0 100% /snap/gnome-calculator/536
/dev/loop22        157184     157184          0 100% /snap/chromium/958
/dev/loop23        144128     144128          0 100% /snap/gnome-3-26-1604/98
/dev/sdb1       492127240  409174612   57930932  88% /home
tmpfs             1630460         16    1630444   1% /run/user/121
tmpfs             1630460        140    1630320   1% /run/user/1001
tmpfs             1630460          0    1630460   0% /run/user/0

Edit for sudo fdisk -l

The question was changed today so here is how you can remove the extra output without resorting to deleting all your snaps and being left without a calculator and what not:

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

As this can be hard to remember you could create an alias in your ~/.bashrc:

alias fdsk="sudo fdisk -l | sed -e '/Disk \/dev\/loop/,+5d'"

Then simply type fdsk in the command line and enter your password when prompted.


As mentioned in comments /dev/loop99 are snap file system images described here:

  • Small snap loop devices visible in gnome-disk-utility OR what is the function of snap ubuntu-core

Assuming you don't want to uninstall all your snaps, your next best option is to hide them from output by appending | grep -v ^/dev/loop. For example:

$ df | grep -v ^/dev/loop

Filesystem      1K-blocks      Used Available Use% Mounted on
udev              3978476         0   3978476   0% /dev
tmpfs              802400      1688    800712   1% /run
/dev/nvme0n1p6   46445360  33133368  11159560  75% /
tmpfs             4011984    227448   3784536   6% /dev/shm
tmpfs                5120         4      5116   1% /run/lock
tmpfs             4011984         0   4011984   0% /sys/fs/cgroup
/dev/nvme0n1p8    9485308   1890272   7595036  20% /mnt/e
/dev/nvme0n1p10  27937812  22501880   3993732  85% /mnt/clone
/dev/nvme0n1p7   23734708  19316220   3189796  86% /mnt/old
/dev/nvme0n1p4  380829660 169799196 211030464  45% /mnt/c
/dev/nvme0n1p2      97280     33222     64058  35% /boot/efi
/dev/sda3       963668988  43929712 919739276   5% /mnt/d
tmpfs              802400        60    802340   1% /run/user/1000

All your loop mounted devices appear to be snaps. If (as you've indicated) you really don't want any of them refer to man snap.

Here's the related excerpt:

 remove
       Remove snaps from the system

       The remove command removes the named snap instance from the system.

       By default all the snap revisions are removed, including their data and the common data direc‐
       tory. When a --revision option is passed only the specified revision is removed.

       Usage: snap remove [remove-OPTIONS]

       --no-wait
              Do not wait for the operation to finish but just print the change id.

       --revision
              Remove only the given revision

       --purge
              Remove the snap without saving a snapshot of its data

and an example: snap remove --purge gphoto2

As mentioned on the man page the --purge switch removes the snap without saving a snapshot of its data. As mentioned in this comment you may wish to find non-snap alternatives to these snap apps.

The Ubuntu Package Search page may be useful in helping you with the search for deb packages with corresponding features.

Attention: As mentioned in this answer While you could unmount the directory and delete the core snap, you'd break all installed snaps doing this, and the system will make it hard for you to do that as a result.

As a side note, it's important to understand that snap packages strengths and weaknesses are the same and much of the criticism surrounding these packages is the same as the accolades. Automatic updating of snaps is both hated and loved depending on who you ask. The read only loop mounted snaps are a boon to some and an annoyance to others. You can find out more about that at https://en.wikipedia.org/wiki/Snappy_(package_manager)

Many of the articles referenced in the Wikipedia article are worth reading as well.