Account Links: Cart | Your Account | Logout

Skip to content

Red Hat Knowledgebase

Red Hat Knowledgebase Search:

Updated Within the Last:

New Solutions within the last day New Solutions within the last week New Solutions within the last month

Browse by topics:


Click to View a Topic
Red Hat Enterprise Linux > AS/ES/WS Basics > Issue <<  170 of 908 >>

Solution Tools:


Email a Solution Postcard Printer version Submit a comment on this answer Update notifications Request an answer Back

Article Reference

Article ID: 4006
Last update: 08-28-06
Issue:
What is a loopback device and how can I create more of them?
Resolution:

A loopback device is used to access filesystems that are not associated with a block device (Hard Disk drives and CD-ROM drives are examples of block devices).

For example, an ISO image (Like the ones available for download from Red Hat Network (RHN) Easy ISO's section) is a file that contains a filesystem image. Linux uses the combination of a loopback device and a special device file to enable the filesystem image to be mounted and read as if it were a real disk or block device.

The rest of this article assumes that the system is using the 2.4 or 2.6 series kernels and that it has the loopback capability as a module. Standard Red Hat kernels have loopback support in the 'loop' module.

By default there are 7 devices available, named /dev/loop0 through to /dev/loop7 .

Creating additional loopback device 'nodes'

If there is ever a need to create additional devices, this can be done by following these steps:

  1. List the loop devices:
    #  ls -l /dev/loop*
    brw-r-----  1 root disk 7,  0 Jul 24 17:49 /dev/loop0
    brw-r-----  1 root disk 7,  1 Jul 24 17:49 /dev/loop1
    brw-r-----  1 root disk 7,  2 Jul 24 17:49 /dev/loop2
    brw-r-----  1 root disk 7,  3 Jul 24 17:49 /dev/loop3
    brw-r-----  1 root disk 7,  4 Jul 24 17:49 /dev/loop4
    brw-r-----  1 root disk 7,  5 Jul 24 17:49 /dev/loop5
    brw-r-----  1 root disk 7,  6 Jul 24 17:49 /dev/loop6
    brw-r-----  1 root disk 7,  7 Jul 24 17:49 /dev/loop7
    
    
  2. Create a new device node with the mknod program:
    # mknod -m660 /dev/loop8 b 7 8
    
  3. This command creates the device node using the options:
    • -m660
      sets the initial modes or permissions of the device node
    • /dev/loop8
      the name of the device node
    • b
      creates a special block (buffered) device
    • 7 8
      MAJOR and MINOR numbers 7 and 8. The MAJOR number for loopback devices is standardized to use value 7. By convention, /dev/loop0 has MINOR 0, and each loopback device node up to /dev/loop7 has a sequential value up to 7. Adding one more, we have the MINOR value incremented by one ( 8 )
  4. Verify the device node has been created:
    #  ls -l /dev/loop8
    brw-rw----    1 root     root       7,  8 Oct  3 14:54 /dev/loop8
                            
  5. Set the ownership correctly and verify the ownership:
    # chown root.disk /dev/loop8
    #  ls -l /dev/loop8
    brw-rw----    1 root     disk       7,  8 Oct  3 14:54 /dev/loop8
                            

Limiting the number of loopback devices allowed

For those using the 2.4 and above series kernels, an option is available for the loop module to limit the number of loopback devices allowed. There is an absolute maximum of 256 devices. The default limit is set to 8 on a Red Hat Enterprise Linux 3 installation.

The loop module may be queried to see the options available:

# modinfo loop
filename:       /lib/modules/2.6.9-34.0.1.ELsmp/kernel/drivers/block/loop.ko
parm:           max_loop:Maximum number of loop devices (1-256)
license:        GPL
alias:          block-major-7-*
vermagic:       2.6.9-34.0.1.ELsmp SMP 686 REGPARM 4KSTACKS gcc-3.4
depends:

To set the limit to 64 devices, edit the /etc/modules.conf file, adding an options line for the loop module:

# cat /etc/modules.conf
...
options loop max_loop=64
... 
                        

When the loop module is loaded or when the system is rebooted, the new setting will take effect.


How well did this entry answer your question?


good wrong incomplete out of date
Red Hat Enterprise Linux > AS/ES/WS Basics > Issue <<   170  of  908  >>