Hi, Richard Owlett wrote: > IIRC there was a limit on the number of loop devices created {8?}. > Is there any default limit now?
That would be man losetup and https://www.kernel.org/doc/Documentation/admin-guide/devices.txt The former seems to tell no limitation. The latter lists "loopback devices" for "major" number 7 with unlimited range for the "minor" device number. The "minor" number is the one that gets appended to the "/dev/loop" name. IIRC this "unlimited" range traditionally means 0 to 255. But the dev_t variable in the result of stat(2) reserves 20 bits for the minor number: https://github.com/torvalds/linux/blob/master/include/linux/kdev_t.h So this numbering might reach up to a million. As experiment, a normal user creates a file of 1 MiB $ dd if=/dev/zero bs=1M count=1 of=/tmp/loop_test 1+0 records in 1+0 records out 1048576 bytes (1.0 MB) copied, 0.00240163 s, 437 MB/s $ and the superuser connects it to loop device 1000: # losetup /dev/loop1000 /tmp/loop_test # Checking the status of the device looks ok: # losetup /dev/loop1000 /dev/loop1000: [2066]:5899 (/tmp/loop_test) # (Don't ask me what the numbers mean ...) To remove the device association: # losetup -d /dev/loop1000 # losetup /dev/loop1000 losetup: /dev/loop1000: No such file or directory # Despite the error message the device file still exists. $ ls -l /dev/loop1000 brw-rw---- 1 root disk 7, 1000 May 15 17:34 /dev/loop1000 (This is a fine example why any re-use of Unix error numbers should be well thought. Here it was not so well done. losetup names the device file but reports about its lack of association to a data file. That data file does still exist, too. So no file is missing here.) Now i remove the file /tmp/loop_test, but keep the device file /dev/loop1000 out of superstition. It brings bad luck to delete in /dev. > Also, I notice the phrase "auto-destruction of loop devices". Reading the whole phrase it becomes clear that this is just about properly cleaning up after umount: Since Linux 2.6.25 auto-destruction of loop devices is supported, mean‐ ing that any loop device allocated by mount will be freed by umount independently of /etc/mtab. > Might I lose one (or more) of my loop devices > without some intentional explicit action by me????? You lose the association, which was created by mount. I expect that you don't lose the device file. But even if the device file vanishes, the next mount or losetup will create it again, if that same loop device number is desired. I use loop mounting often and did not notice any special risk of it. Have a nice day :) Thomas