3. Adding Support for More Loop Devices

Newer Linux kernels (2.4) allow you to add more loop devices easily by editing /etc/modules.conf or through the use of a boot parameter.

Older kernels (2.2 ?) only had support for 8 loop devices compiled into the kernel. In short, you were only able to share 8 CD's on a network with this default value. In order to support more than that default, you needed to modify the kernel source and recompile a new kernel.

Use the following methods to determine which version of the kernel you are running.

bash# uname -a


bash# cat /proc/version

3.1. Adding the Loop Module Option

Current kernels allow you to set the number of loop devices supported without recompiling the kernel. One of these methods is to add an options line to /etc/modules.conf. This method will only work if your loop support has been configured as a loadable kernel module (which is how most major Linux distributions come preconfigured now).

Edit /etc/modules.conf and add the following line.

options loop max_loop=64

After making the above change, simply reboot. Or you can try to use rmmod and insmod to make the change on the fly - but this will not work if you currently have any loop devices mounted (you'll get an error saying loop: Device or resource busy).


If you do not have an /etc/modules.conf file, your module configuration file may be called /etc/conf.modules (this name is now deprecated).

Continue with Section 3.4.

Thanks to Paul A. Sand for pointing out the /etc/modules.conf option.

3.2. Appending to the Boot Prompt

If your loop support has been compiled directly into the kernel (in other words, it is not loaded as a module), you can append the number of loop devices you would like to support at the linux boot prompt.

boot:  linux max_loop=64

Or, if you are using LILO, you can edit your linux boot stanza in /etc/lilo.conf and add/modify the append= line. Here is an example stanza showing append= (note: only add or modify the append line, don't change your whole stanza to look like this one or your system may not boot). For more information about LILO, consult the LILO mini-HOWTO at http://www.linuxdoc.org/HOWTO/mini/LILO.html.


	append=" max_loop=64"


After changing /etc/lilo.conf, you need to run the lilo command for your changes to take effect.

bash# lilo

Added linux *
Added linux-nonfb
Added failsafe
Added windows
Added floppy

Next restart your system. After your system restarts, you can check your boot command line by typing the following:

bash# cat /proc/cmdline


I am not sure if the loop module (compiled as a module) reads /proc/cmdline when the module is loaded, and therefore may not need an options line /etc/modules.conf. It's possible that it can (and if it doesn't, it should). To summarize: I have not tested this.

Continue with Section 3.4.

Thanks to Tony Melia for the boot prompt info.

3.3. Tweaking the Kernel

If you have an older kernel (v. 2.2) or if you are completely comfortable recompiling the kernel, you can increase the number of loop devices supported by editing the /usr/src/linux/drivers/block/loop.c file.


If you find that the kernel sources are not installed on your machine, you'll need to consult your Linux Distribution's documentation on how to install them (the Kernel Sources come with all distributions - it's part of the GNU GPL licensing).

Change the number in the following line to however many loop devices you'll need.

#define MAX_LOOP 16

Compile the new kernel or module as the case may be. If you need some help getting started with this, read /usr/src/linux/README or consult The Linux Kernel HOWTO.

Continue with Section 3.4.

3.4. Creating the Loop Devices in /dev

You should check how many /dev entries you have for loop devices.

bash# ls -l /dev/loop*

The mknod command creates the devices in the /dev directory. The loop devices have a major number of "7", and the minor numbers begin at "0". If your MAX_LOOP was defined as "8" in /usr/src/linux/drivers/block/loop.c, you should have /dev/loop0 through /dev/loop7. To create the /dev/loop8 device, use the following command (subsitute the appropriate number you need for both the "8's" in the example below).

bash# mknod -m660 /dev/loop8 b 7 8

Check Owner/Group & Permissions on the new file (using ls -l). You can change the owner and group with the following command:

bash# chown root.disk /dev/loop8

You can change the permissions using the following command:

bash# chmod 666 /dev/loop8