# loop only mounts 8 devices

## cristi1979

I have a problem with loop: I can only mount 8 devices. Before I remember I did managed to mount more then 8.

When I try to mount the 9th device I get "mount: could not find any free loop device":

```
gentoo cristi # mount /media/Audio/squash_files/usr_share.sq /mnt/AUFS2/root_ro/usr/share/ -o loop

mount: could not find any free loop device

```

Here is some info related to loop from my system:

 - modprobe.d:

```
gentoo cristi # cat /etc/modprobe.d/loop.conf

options loop max_loop=20

```

 - modprobe.conf:

```
gentoo cristi # cat /etc/modprobe.conf | grep loop

alias loop-xfer-gen-0   loop_gen

alias loop-xfer-3       loop_fish2

alias loop-xfer-gen-10  loop_gen

### update-modules: start processing /etc/modprobe.d/loop.conf

options loop max_loop=20

### update-modules: end processing /etc/modprobe.d/loop.conf

```

 - in /dev:

```
gentoo cristi # ls /dev/loop

0  1  10  11  12  13  14  15  16  17  18  19  2  3  4  5  6  7  8  9

```

 - losetup:

```
gentoo cristi # losetup /dev/loop7

/dev/loop7: [000f]:10903 (/mnt/AUFS2/tmpfs_squash/sbin.sq)

gentoo cristi # losetup /dev/loop8

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

```

 - df output:

```

gentoo cristi # df

Filesystem           1K-blocks      Used Available Use% Mounted on

rootfs                 9621848   7130828   2002244  79% /

/dev/root              9621848   7130828   2002244  79% /

rc-svcdir                 1024       124       900  13% /lib64/rc/init.d

udev                     10240       196     10044   2% /dev

shm                    3064764        24   3064740   1% /dev/shm

/dev/sda5                97826     24408     68199  27% /boot

/dev/sda7              9614116   4087000   5038744  45% /home

none                   1048576        16   1048560   1% /tmp

none                   1048576    159484    889092  16% /var/tmp

/dev/sdb5             94749868  62782464  27154332  70% /media/Audio

tmpfs                  1000448    992260      8188 100% /mnt/AUFS2/tmpfs_squash

/dev/loop1              562048    562048         0 100% /mnt/AUFS2/root_ro/usr/lib64

/dev/loop2               30464     30464         0 100% /mnt/AUFS2/root_ro/usr/libexec

/dev/loop3               48256     48256         0 100% /mnt/AUFS2/root_ro/lib64

/dev/loop4               11776     11776         0 100% /mnt/AUFS2/root_ro/usr/sbin

/dev/loop5                3968      3968         0 100% /mnt/AUFS2/root_ro/bin

/dev/loop6              198912    198912         0 100% /mnt/AUFS2/root_ro/opt

/dev/loop7                5888      5888         0 100% /mnt/AUFS2/root_ro/sbin

/dev/sda9            144181428 124785240  12072160  92% /media/Musica

/dev/loop0               79744     79744         0 100% /mnt/AUFS2/root_ro/usr/portage

```

Thanks for any help.

----------

## nixnut

you don't have the loop nodes /dev/loop8 to /dev/loop15. You could try generating them with mknod

----------

## cristi1979

why do you say that?

```
gentoo cristi # ls /dev/loop*

/dev/loop0   /dev/loop11  /dev/loop14  /dev/loop17  /dev/loop2  /dev/loop5  /dev/loop8

/dev/loop1   /dev/loop12  /dev/loop15  /dev/loop18  /dev/loop3  /dev/loop6  /dev/loop9

/dev/loop10  /dev/loop13  /dev/loop16  /dev/loop19  /dev/loop4  /dev/loop7

/dev/loop:

0  1  10  11  12  13  14  15  16  17  18  19  2  3  4  5  6  7  8  9

```

This info was in my previous post also:

gentoo cristi # ls /dev/loop

0  1  10  11  12  13  14  15  16  17  18  19  2  3  4  5  6  7  8  9 

I have 8 and 15 from what I can see, but I may be wrong. 

So, why do you say i don't have those nodes?

----------

## mv

You must pass the kernel loop module the maximal number of loop devices.

----------

## cristi1979

I have unmounted all my loop devices

Squash dirs is a bash script that mounts squash files:

gentoo linux # modprobe loop max_loop=64

gentoo linux # /squash_dirs.sh.tmp

mount: could not find any free loop device

mount: could not find any free loop device

mount: could not find any free loop device

mount: could not find any free loop device

You can see that I still have this problem. It will only mount 8 devices.

Again, if I understood you wrong, please let me know.

----------

## nixnut

 *cristi1979 wrote:*   

> 
> 
> This info was in my previous post also:
> 
> 

 Nope, that showed the contents of the directory /dev/loop, not the /dev/loop* devices. But your additional information showed my assumption was wrong anyway. Sorry, no idea then.

----------

## nixnut

 *mv wrote:*   

> You must pass the kernel loop module the maximal number of loop devices.

 

He does, see his modprobe.conf. 

@cristi1979: have you tried unloading and reloading the loop driver?

----------

## cristi1979

Yes, i did. It takes into consideration the max_loop parameter:

 - if max_loop <= 8, I will only be able to mount the number I passed to loop module and it will create only that number of devices

 - if max_loop > 8, it will create the correct number of devices, but I will only be able to mount 8 of them

I've also tried gentoo kernels2.6.28, all 2.6.29 and git 2.6.30 and updated udev to 142, all with the same results.

It does'n mater what I mount, iso or squashfs files.

And it worked a few weeks ago. I have no idea what happened.

Still searching.

----------

## salahx

You nay want to look into dm-loop. Unfortunately, its not part of the main kernel sources, and the status of merging it is unclear: https://www.redhat.com/archives/dm-devel/2009-January/msg00068.html . 

Note for the startand loopback devices, there's a max_loop boot parameter (if loop is module, you may need to set this in /etc/modprobe.d .

----------

## cristi1979

Thank you for the sugestion salahx, but it looks too risky.

What I did found out is that the problem is not from my kernel:

 - booted Ubuntu kernel in Gentoo: same problem

 - booted Gentoo kernel in Ubuntu: I've mounted 9 iso files

So the problem seems to be from user space.

Does anyone know what could interfere with this? Hal, udev, something else?

----------

## cristi1979

Or how can I remove the /dev/ dir and created a fresh one?

----------

## cristi1979

The same thing happens when I create the devices manually.

I even modified the number of devices in loop.c.

Now, when I boot, I have 32 devices created, but I still can mount only 8 of them.

----------

## cristi1979

After installing a Gentoo system in VirtualBox, I managed to pinpoint what is causing me problems: 

=sys-apps/util-linux-2.15

After I downgraded to sys-apps/util-linux-2.14.2, I can mount more then 8 devices.

Any idea if I should leave it like this or where to open a bug?

----------

## NeddySeagoon

cristi1979,

Post a bug to bugs.gentoo.org but read the changelog first.  It may have been a deliberate change.

That would make the bug a feature request.

----------

## cristi1979

Just for reference:

https://bugs.gentoo.org/show_bug.cgi?id=270774

----------

## doctork

I have loop compiled into the kernel (2.6.29-gentoo-r4) rather than a module.  If I boot with max_loop=16 as a parameter I see the necessary /dev entries created.

```
 Entry in grub.conf:

title=Latest Config

root (hd0,0)

kernel /vmlinuz real_root=/dev/sda3 max_loop=16
```

and

```
$ls /dev/loop*

/dev/loop0   /dev/loop11  /dev/loop14  /dev/loop3  /dev/loop6  /dev/loop9

/dev/loop1   /dev/loop12  /dev/loop15  /dev/loop4  /dev/loop7

/dev/loop10  /dev/loop13  /dev/loop2   /dev/loop5  /dev/loop8

/dev/loop:

0  1  10  11  12  13  14  15  2  3  4  5  6  7  8  9

```

Note that I haven't acutally tried to use any of them.

EDIT:

I checked, and I can mount ISOs on /dev/loop1, /dev/loop10, and loop15.

--

doc

----------

## cristi1979

Thank you doctork, but I don't think you understood my problem: I have the devices, but I can't mount more then 8 of them (for example all loops from loop1 to loop 15).

And apparently the problem is from util-linux, which relies on loop devices to be created in /dev/loop/. Udev is creating the devices in /dev/ and symlinks in /dev/loop/.

----------

## doctork

Oh, I understood you just fine.  I'm saying I can mount more than eight ISOs:

```
media-x2 isos # mount | grep isos

/home/isos/pm0.iso on /tmp/mnt0 type iso9660 (rw,loop=/dev/loop0)

/home/isos/pm1.iso on /tmp/mnt1 type iso9660 (rw,loop=/dev/loop1)

/home/isos/pm2.iso on /tmp/mnt2 type iso9660 (rw,loop=/dev/loop2)

/home/isos/pm3.iso on /tmp/mnt3 type iso9660 (rw,loop=/dev/loop3)

/home/isos/pm4.iso on /tmp/mnt4 type iso9660 (rw,loop=/dev/loop4)

/home/isos/pm5.iso on /tmp/mnt5 type iso9660 (rw,loop=/dev/loop5)

/home/isos/pm6.iso on /tmp/mnt6 type iso9660 (rw,loop=/dev/loop6)

/home/isos/pm7.iso on /tmp/mnt7 type iso9660 (rw,loop=/dev/loop7)

/home/isos/pm8.iso on /tmp/mnt8 type iso9660 (rw,loop=/dev/loop8)

/home/isos/pm9.iso on /tmp/mnt9 type iso9660 (rw,loop=/dev/loop9)

```

--

doc

----------

## cristi1979

Can you please tell me what version for util-linux you have installed?

----------

## doctork

I'm using this one:

```
sys-apps/util-linux-2.14.2
```

--

doc

----------

## cristi1979

OK, thank you.

I'm using now the same version and it's working for me too, but, if you read some previous posts, the problems I have are because of util-linux-2.15.

----------

