Linux Loop Devices
This post was last updated on June 1st, 2020 at 07:00 pm
By default you have 8 loop devices (loop0 – loop7). You can extend this number up to 255 (maybe even 256, I haven’t tested it that high).
Have the kernel source tree installed along with all the other development packages needed in order to build a kernel. This may be done by just redoing the loop.o module; however, I don’t have instructions on doing that so I will show you the method I know. If you need to know what packages you need to have installed, then check http://www.cpqlinux.com/kernel.html.
Find the line that says:
#define MAX_LOOP 8
Leave the line exactly as is (with the # sign in front) and only change the 8 to a 255. The new line would look like:
#define MAX_LOOP 255
Save the file and exit from the editor.
Now when you build this as a module you will now have the ability to use more loop devices.
Build the module. The only way I know to get everything to build right is to go through the whole kernel build routine (http://www.cpqlinux.com/kernel.html). Once you build the module and kernel and put them into place and run /sbin/lilo, then you are ready to add device nodes.
Device nodes are required to access the loop devices. You already have loop0 – loop7. You can run the following loop to create the rest of the nodes (loop8 – loop255). You can type all of the following lines of code on one single line if you leave off the trailing “\” characters.
C=8; echo; echo "Creating loop device nodes."; \ while [ $C -lt 256 ]; do mknod /dev/loop$C b 7 $C; \ echo -n .; C=`expr $C + 1`; done; echo;
Note: the quoting around the expr section are called backtick’s and they are located with the tilde character (“~”) in the upper left hand corner of the keyboard. The character is not a single quote.
Now once you have rebooted and loaded the new kernel and loop.o module, and created your device nodes, you are ready to use more than 8 loop devices.
mount -t iso9660 /tmp/rh61.iso /mnt/rh61 -o loop
mount -t vfat /tmp/boot.img /mnt/boot -o loop
mount -t iso9660 /home/ftp/pub/RedHat70/disk1.iso
/home/ftp/pub/RedHat70/disk1 -o loop
Now you don’t have to stop when you get to your old limit of 8.
There is a soft limit that will get in the way. The following script will show this to you:
Script for testing maximum number of loop devices you can get on a Linux server:
You might also like
This post was last updated on May 26th, 2020 at 09:50 pmStandard MBR functionality can be restored by adding proper boot code back into the MBR. This document will mostly
This post was last updated on May 26th, 2020 at 10:43 pm Contents0.1 What to do with static drivers, module drivers, append=, and insmod.0.2 Drivers in Linux can take on
This post was last updated on May 27th, 2020 at 05:23 pm Please refer to rhdiskmod.html for complete information. That page will eventually replace this page. Contents1 Unpacking an initrd2