CuriousKimchi CuriousKimchi - 1 year ago 96
Linux Question

A new loop device won't properly be created in RHEL4

As the title, I'm on RHEL 4.
Currently, there are /dev/loop0 ~ /dev/loop7 (eight devices) created that seems to work fine.

When I try to create a new device, loop8, by calling

mknod /dev/loop8 b 7 8
chown --reference=/dev/loop0 /dev/loop8
chmod --reference=/dev/loop0 /dev/loop8

a device seems to be created, but it doesn't work as intended.

First, as shown on the link, we can see loop8.
Terminal output picture

However, using
on the two creates different outputs as below.

losetup /dev/loop0
loop: can't get info on device /dev/loop0: No such device or address

losetup /dev/loop8
loop: can't open device /dev/loop8: No such device or address

Now let me create two files and setup the two loop devices. As in the link, loop0 succeeds while loop8 fails.Two device comparison

Why is this the case?

PS. On an extra note, if I restart the computer, it always has loop0~loop7 even if you create or remove any loop devices. Furthermore, as shown in the first link, the time they are edited are all at bootup. Finally, even if you setup /dev/loop0 with a file, after computer reboot, despite /dev/loop0 existing, /dev/loop0 is no longer set up. I have no idea why these are happening.

Answer Source

8 is the default number of loop devices. You need to pass an option to the loop module to increase this:

Also, mounting a file via loop device is not persistent, just like mounting anything is not persistent, unless you add it to /etc/fstab.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download