Penguin
Note: You are viewing an old revision of this page. View the current version.

Loopback mounting is a way of mounting an image of a disk. This is useful if you are preparing a disk image for installation but do don't have the actual physical device handy.

Determining Partition Offsets

If you're trying to mount a partition of a disk image that has been created via dd(1) or similar you will likely need to specify an offset to where the partition starts in the disk image. This offset can then be passed as an option to the mount command.

The offset can be determined by using fdisk to find out which sector the partition starts on and then multiplying that number by the sector size (which is also helpfully printed by fdisk). See the example below:

matt@argon:~/crcnet/ecn$ fdisk -u -l ecn-base.img
You must set cylinders.
You can do this from the extra functions menu.

Disk ecn-base.img: 0 MB, 0 bytes
4 heads, 62 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes

       Device Boot      Start         End      Blocks   Id  System
ecn-base.img1              62      250727      125333   83  Linux

There is one partition, starting at sector 62 which equates to offset (62*512 = 31774) which can then be mounted like so:

matt@argon:~/crcnet/ecn$ sudo mount -o loop,offset=31744 -t ext2 ecn-base.img img/
matt@argon:~/crcnet/ecn$ cd img/
matt@argon:~/crcnet/ecn/img$ ls
bin   dev  lib         packages  root  tmp  var
boot  etc  lost+found  proc      sbin  usr  var.tgz

CategoryDiskNotes


See also LoopDevice