Updated: 28 September 2026 · Applies to: Linux kernels 5.14 to 6.x on AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10, Ubuntu 24.04 and 26.04, Debian 13
A loop device makes a file, such as a disk image or an ISO, usable as a block device. Older guides for CentOS 5 and 6 explain how to raise a fixed limit of 8 loop devices. On current kernels that limit no longer exists: loop devices are created on demand, so you normally do not need to change anything. We checked this in the Linux 6.12 source and tested it on a running system.
How it works now
losetup asks the kernel for a free loop device through /dev/loop-control, and the kernel creates a new one when all existing devices are in use:
losetup --find --show disk.img # attach the file to the next free device and print its name losetup -l # list attached devices losetup -d /dev/loop8 # detach one
mount -o loop disk.img /mnt uses the same mechanism. The AlmaLinux 9 and 10 kernels create no loop devices at boot at all (CONFIG_BLK_DEV_LOOP_MIN_COUNT=0), and the Ubuntu 24.04 kernel creates 8; both add more as they are needed.
Pre-create devices for older programs
Some programs look for existing /dev/loopN files instead of asking /dev/loop-control. For them, create a number of devices at boot with the max_loop parameter of the loop driver.
On AlmaLinux, Rocky Linux and RHEL, loop is a kernel module, so you can set the parameter in /etc/modprobe.d/loop.conf:
options loop max_loop=64
It takes effect the next time the module loads, normally at the next reboot. To set it on the kernel command line instead, which works whether loop is built in or a module:
grubby --update-kernel=ALL --args="loop.max_loop=64" # AlmaLinux, Rocky Linux, RHEL
On Ubuntu the loop driver is built into the kernel, so only the kernel command line works. On Ubuntu and Debian, add loop.max_loop=64 to GRUB_CMDLINE_LINUX in /etc/default/grub and run update-grub. Check after a reboot with cat /sys/module/loop/parameters/max_loop.
Setting max_loop also limits which device numbers the kernel creates when a program opens a missing /dev/loopN file directly. Devices requested through /dev/loop-control are not limited by it.
Inside containers
In a container or chroot where /dev is a fixed copy, the kernel can create a new loop device but its /dev/loopN file does not appear, and losetup fails with "No such file or directory". Create the device files by hand (loop devices have major number 7):
for i in $(seq 8 31); do [ -e /dev/loop$i ] || mknod -m 0660 /dev/loop$i b 7 $i; done
The container also needs permission to use loop devices, which usually means a privileged container.
Official documentation: loop(4) manual and losetup(8) manual.