Using /dev/loop to view a CD image

This tip explains how to use the loop device to view or share files from a CD image or ISO file.

First, you need to make sure you have support in your kernel. It can be configured as a module so there's no need to reboot if you don't have support.

Code Listing 1: Installing the kernel module

// configure the following option"
Block Devices
-> Loopback device support

# make dep && make modules modules_install
# insmod loop

To view the contents of an iso file, just mount the iso on a loopback device. For example, here we mount gentoo-basic-x86-1.4_rc4.iso to gentoo-1.4_rc4/.

Code Listing 2: Mounting an iso on a loopback device

# mount gentoo-basic-x86-1.4_rc4.iso gentoo-1.4_rc4 -o loop=/dev/loop1,blocksize=1024

Now you can view the directory gentoo-1.4_rc4 just as if it were part of your regular filesystem.

From http://www.gentoo.org/news/en/gwn/20030414-newsletter.xml

rate this article:
current rating: average rating: 1.0 (45 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)