6

When I try to mount an ISO image with mount -o loop I get

mount: could not find any free loop device

Running losetup -a shows

/dev/loop0: [0005]:2464 (/dev/sda1)
/dev/loop1: [0005]:3439 (/dev/loop0)
/dev/loop2: [0005]:4482 (/dev/loop1)
/dev/loop3: [0005]:4486 (/dev/loop2)
/dev/loop4: [0005]:4490 (/dev/loop3)
/dev/loop5: [0005]:4494 (/dev/loop4)
/dev/loop6: [0005]:4498 (/dev/loop5)
/dev/loop7: [0005]:4502 (/dev/loop6)

What is the purpose of a loop device which refers to sda1? And what is the purpose of all the other loop devices referring to the previous one?

Is it safe for me to disconnect these loop devices so that I can use them? If so how do I do so? (Running losetup -d /dev/loop[0-7] gives loop device is busy.) If I cannot disconnect these, how do I create new loop devices that I can use for mounting ISO images?

p.s. I am running Debian "wheezy" v 7.1.0.

4
  • Afaik there is a parameter for the loop device driver so you could use e.g. 16 devices. Check the source, Monad.
    – ott--
    Aug 1, 2013 at 21:54
  • @ott Which source are you referring to?
    – Code-Guru
    Aug 1, 2013 at 23:47
  • loop device driver in the kernel source.
    – ott--
    Aug 2, 2013 at 11:25
  • "losetup -D" will clear all the used devices, just in case you really want to clear stuff you don't need.
    – F.L
    Jul 5, 2017 at 22:35

2 Answers 2

6

Take a look and see if there are any mounts using any of the above loopback devices. You can use the mount command to see this:

$ mount

If they are mounted, they you'll likely need to unmount (umount) them prior to getting losetup -d <loopdevice> to detaching them.

$ umount /dev/some/mount

As to if it's safe or not, that really depends on what these are being used for. I'd probably hold off till I had a better grasp of what these loop devices are for, before I started unmounting them. Just a guess but they might have something to do with an encrypted drive.

Therefore I'd create another one just to be safe.

making another loop device

Here are the steps:

$ sudo mknod -m640 /dev/loop8 b 7 8
  • -m640 define the permission of the device
  • /dev/loop8 define the name of the device
  • b for the creation of the special block device
  • 7 8 the number 7 AND 8 define the MAJOR AND the MINOR

Check if the loop is created:

$ ls -l /dev/loop8
brw-r----- 1 root root 7, 8 Oct 3 14:54 /dev/loop8

Now set ownership on the device:

$ sudo chown root:disk /dev/loop8

References

4

FYI, the MINOR number referred to in the previous answer must increment with the loop number. I'm mounting a whole bunch of ISOs, so I need a bunch of devices. I wrote this short script to create devices 8-30:

    #!/bin/bash
    for i in {8..30};
    do
        /bin/mknod -m640 /dev/loop$i b 7 $i
        /bin/chown root:disk /dev/loop$i
    done

Also, if you make a mistake, or need to remove devices, you can just rm the device.
For example: sudo rm /dev/loop8

1
  • 1
    Update: I have about 50 ISOs mounted to loop devices. When I rebooted, the system hung because it couldn't find enough loop devices to remount them all. To fix this, I added GRUB_CMDLINE_LINUX_DEFAULT="max_loop=64" to /etc/default/grub on my Ubuntu system, and then ran update-grub2 to update the grub config.
    – jars99
    Mar 25, 2015 at 18:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .