Benutzer jetzt online: 472 - AnmeldenSprache: en, de, mehr , übersetzen 

Wie man Loop-Dateien einbindet

Ein bisschen Geschichte

Alte Linux versionen (vor 2.6.23) hatten eine strikt begrenzte Anzahl von loopback geräten (/dev/loop*). Das Standard Maximum war auf 8 gestellt, es sei denn ein max_loop Boot Parameter wurde gesetzt. Dank diesem Parameter konnten Benutzer bis zu 256 loop Geräte aktivieren. Udev war für die Erstellung aller 256 loop Dateien in /dev/loop/ zuständig.

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.

 

Die aktuelle 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.

 

Fehler Meldung "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:

# zunächst erstellen Sie ein neues loop Gerät
mknod /dev/loop/300 b 7 300

# dann weisen Sie ihre loop Datei dem neuen loop Gerät zu
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/

# wenn Sie dann unmounten wollen, verwenden Sie
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:

NEW_LOOP=$(mknod_next_loop_dev)
losetup $NEW_LOOP your_file
mount $NEW_LOOP /your/mount/directory


Visit Tomas M's blog for fun, mostly on religious idiocy.