Loop devices with backing file less than 512B are not listed in /proc/partitions
, which losetup uses to look up loop devices. I believe the reason why it is not listed there is that by creating such loop device, you get block device which is smaller than its blocksize (512B in case of loop device).
So while losetup and kernel allows you to create loop device which is smaller than 512B, you can not use it anyways (cannot read or write to it, blocksize --getsize returns 0
). The only thing you can do with such device is - as far as I understand - to grow the backing file and call losetup -c /dev/loopX
- if the backing file >=512B, the loop device now appears in /proc/partitions
and $(losetup -a)
.
The ability to losetup -c
is IMHO the reason why the kernel supports creating loopdevice with <511B backing file instead of returning an error.