mount could not find any free loop device

If you like to play with lots of ISO files at the same time, you will inevitably encounter the below error while mounting the ISO files as loop devices.

root@vikas027:~# mount -a
mount: could not find any free loop device
root@vikas027:~#

I have a PXE Kickstart Server for which I need to mount numerous ISO (RHEL, OEL, Ubuntu, Debian, etc) files at the same time so that the can serve as Kickstart installation trees and yum repositories.

By default Linux (RHEL and Ubuntu at least) kernel supports 8 loop device files, i.e. one can only mount 8 ISOs at the same time.

Fortunately, we can add block device files using mknod as below to mount more ISOs. All we need to take care of is major and minor numbers.

root@vikas027:~# ls -l /dev/loop*
brw-rw---- 1 root disk 7, 0 Apr 19 12:26 /dev/loop0
brw-rw---- 1 root disk 7, 1 Apr 19 12:26 /dev/loop1
brw-rw---- 1 root disk 7, 2 Apr 19 12:26 /dev/loop2
brw-rw---- 1 root disk 7, 3 Apr 19 12:26 /dev/loop3
brw-rw---- 1 root disk 7, 4 Apr 19 12:26 /dev/loop4
brw-rw---- 1 root disk 7, 5 Apr 19 12:26 /dev/loop5
brw-rw---- 1 root disk 7, 6 Apr 19 12:26 /dev/loop6
brw-rw---- 1 root disk 7, 7 Apr 19 12:26 /dev/loop7
root@vikas027:~#

root@vikas027:~# mknod -m 0660 /dev/loop8 b 7 8
root@vikas027:~# ls -l /dev/loop8
brw-rw---- 1 root disk 7, 8 Jun 14 17:19 /dev/loop8
root@vikas027:~#
root@vikas027:~# mount -a

I encountered this error in a long flight few weeks ago, and obviously without internet (or Google) I had to scratch my head for few minutes before coming up with this solution. Hope, I have saved some of your time.

comments powered by Disqus