Users online right now: 61 - LoginLanguage: en, more , translate 

How to mount loop files in Slax

A bit of history

Older Linux versions (prior 2.6.23) had a strictly limited amount of loopback devices (/dev/loop*). Default maximum was set to 8, unless a max_loop boot parameter was specified. Thanks to that parameter, user could activate as much as 256 loop devices. Udev was then responsible for creating all the 256 loop files in /dev/loop/.

Even if 256 may be enough for someone, it was not enough for Slax. So Slax participated in sponsorship of a better code in the Linux Kernel, which has been added to the mainline as of 2.6.23.


The current situation

Since Slax 6 is using Linux Kernel 2.6.24 and newer, the limit is not there anymore and you can use as much loop devices as you need. On the other hand, there was a need to retain backward compatibility with all the broken tools (like modprobe, losetup, etc.), which still refuse to work on a loop devices with minor number bigger than 255. So the following approach has been negotiated:

If a max_loop=n boot parameter is specified, it behaves like before, the 'n' becomes a new limit and udev creates 'n' files in /dev/loop/. If the parameter is not specified (it is not in Slax), a loop device per module is created (with a minimum of 8) and you have to mknod more manually, if you need them.


Error message "couldn't find any free loop device"

If you see this error after an attempt to mount -o loop, simply see /dev/loop/* and create a next loop device number using mknod /dev/loop/100 b 7 100. If you reach the limit of 256, you'll need to loop-mount in two steps:

# first create a new loop device
mknod /dev/loop/300 b 7 300

# then assign your loop file to new loop device
losetup /dev/loop/300 your_loop_file.dat

# and finally mount the loop device instead of the file
mount /dev/loop/300 /your_mount_directory/

# if you then need to unmount, use
umount /your_mount_directory/
losetup -d /dev/loop/300

If you wish to create a new loop device automatically in your script, include /usr/lib/liblinuxlive in it and call mknod_next_loop_dev function:

losetup $NEW_LOOP your_file
mount $NEW_LOOP /your/mount/directory

Slax is generously supported by: P&P Software GmbH and wisol technologie GmbH