
There may be more than one file system on the disk anyway and they can’t both begin at block zero on the disk. Most of the time, hard disks are partitioned and a file system does not begin at the start of the disk. The mount command looks for the file system to begin at block zero on the specified block device file. By default, the losetup command (and mount with -o loop) makes a loopback block device that maps to the entire source file, i.e.
#Loopback device iso
That works really well for CD/DVD iso files but you’ll run into problems with disk images. Or do it all in the umount command: umount -d /mount/point Once you are finished, you can unmount the file system in the usual way then detach the file from the loopback device: # umount /mount/point dev/loop0 on /mount/point type ext3 (rw) Mount: going to use the loop device /dev/loop0 The mount program can do the losetup for you: # mount -v -t ext3 /path/to/disk.img /mount/point -o loop I tend to use verbose options when available and I’m not using the command in a script. In the case of losetup it only causes the selected loop device name to be announced. I’ve used the -v option to losetup to get verbose information on the action. You can also specify which loopback device should be used: # losetup -v /dev/loop5 /path/to/disk.img The second one mounts an ext3 file system (if present) from that block device. The first command finds an unused loop device, attaches the /path/todisk.img file to it and tells you which loop device was selected in the /dev tree. In the form above or the shortened form shown below it’s a common way to mount CD/DVD iso images without having to burn them onto physical disks. Now that’s a Cool Solution, it lets you do this: # losetup -v -f /path/to/disk.img
#Loopback device driver
The loopback block driver allows you to access a regular file as if it was a block device. Regular files are not block devices but you can get the mount program to use them if you make them available via a loopback block device. In the case of the mount program, the filename used must be that of a block device file. The normal way to access files on a disk is to mount the file system(s) on the disk. Many of the command line tools for disks only expect a filename as the location of the disk to work with and will actually work with any file. It makes it easy to duplicate disks, create backup images of disks, etc without the overhead of having to re-create the entire directory structure of the source. It’s very convenient that the contents of block devices are exposed as files in Linux.

Converters exist that will create raw images from other formats (see below). So, you cannot immediately use this method with the special disk formats supported by some VM platforms, e.g. It has to be said that the method I’m about to describe only works for disk images that are flat files representing the contents of the disk in logical block order (raw disk images in common VM terminology). Linux has many cool features and some of them can help you access files on the file systems in a file that contains the block by block contents of a disk. I sometimes need to recover files from the file systems on those too.

I also have huge files containing block level archives of retired physical disks. I use them so much now that I often need to access files in them…even when they are not running. As a programmer I find virtual machines very useful. The loopback device can be used for a whole lot more.
#Loopback device how to
You probably know how to mount CD or DVD iso images on Linux using the loopback block device.
