2

Upon listing the blocks using lsblk, I found 14 look blocks listed, from loop 0 to loop 13.

me@alpha:~$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0  87.9M  1 loop /snap/core/5662
loop1    7:1    0 140.7M  1 loop /snap/gnome-3-26-1604/74
loop2    7:2    0   3.7M  1 loop /snap/gnome-system-monitor/57
loop3    7:3    0 140.9M  1 loop /snap/gnome-3-26-1604/70
loop4    7:4    0  34.6M  1 loop /snap/gtk-common-themes/818
loop5    7:5    0  42.1M  1 loop /snap/gtk-common-themes/701
loop6    7:6    0  89.5M  1 loop /snap/core/6130
loop7    7:7    0   2.3M  1 loop /snap/gnome-calculator/238
loop8    7:8    0 130.2M  1 loop /snap/gnome-3-28-1804/4
loop9    7:9    0  14.5M  1 loop /snap/gnome-logs/45
loop10   7:10   0    13M  1 loop /snap/gnome-characters/124
loop11   7:11   0  53.7M  1 loop /snap/core18/536
loop12   7:12   0    13M  1 loop /snap/gnome-characters/139
loop13   7:13   0   2.3M  1 loop /snap/gnome-calculator/260
sda      8:0    0   113G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
└─sda2   8:2    0 112.5G  0 part /

However, when I list using ls /dev and find blocks using grep 'loop', I found 15 blocks listed, with an extra loop14 shown.

me@alpha:~$ ls /dev | grep 'loop'
loop0
loop1
loop10
loop11
loop12
loop13
loop14
loop2
loop3
loop4
loop5
loop6
loop7
loop8
loop9
loop-control

Why loop14 is not listed from lsblk?

3

lsblk lists loop devices with a backing file. In your case, loop devices 0-13 have backing files, and show up.

losetup --find, used to find the next available loop device, automatically creates a new loop device if all existing loop devices are in use (if run as root). So some process might have run losetup --find as root to look for an available loop device, and probably didn't use it.

Example:

I have seven loop devices, all backed:

$ sudo losetup --list --all         
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE
/dev/loop1         0      0         1  1 /var/lib/snapd/snaps/core_5897.snap
/dev/loop6         0      0         0  0 /tmp/foo
/dev/loop4         0      0         0  0 /tmp/foo
/dev/loop2         0      0         1  1 /var/lib/snapd/snaps/core_6130.snap
/dev/loop0         0      0         1  1 /var/lib/snapd/snaps/vuze-vs_3.snap
/dev/loop7         0      0         0  0 /tmp/foo
/dev/loop5         0      0         0  0 /tmp/foo
/dev/loop3         0      0         1  1 /var/lib/snapd/snaps/core_6034.snap
$ ls /dev/loop*
/dev/loop0  /dev/loop2  /dev/loop4  /dev/loop6  /dev/loop-control
/dev/loop1  /dev/loop3  /dev/loop5  /dev/loop7

I ask losetup for the next available loop device as root:

$ sudo losetup --find       
/dev/loop8

And losetup has created this for me:

$ ls /dev/loop*             
/dev/loop0  /dev/loop2  /dev/loop4  /dev/loop6  /dev/loop8
/dev/loop1  /dev/loop3  /dev/loop5  /dev/loop7  /dev/loop-control

But it's not in lsblk:

$ lsblk              
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop1    7:1    0  88.2M  1 loop /snap/core/5897
loop6    7:6    0     1M  0 loop 
loop4    7:4    0     1M  0 loop 
sr0     11:0    1  1024M  0 rom  
loop2    7:2    0  89.5M  1 loop /snap/core/6130
loop0    7:0    0 280.2M  1 loop /snap/vuze-vs/3
loop7    7:7    0     1M  0 loop 
sda      8:0    0    41G  0 disk 
└─sda1   8:1    0    41G  0 part /
loop5    7:5    0     1M  0 loop 
loop3    7:3    0  89.5M  1 loop /snap/core/6034

Because it's not backed by anything usable as a block device.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.