User Tools

Site Tools


Sidebar

Computer Science

Germany

Others

Links

computer_science:software:linux:commands:mount_.img_file

.img files are not images of a partition, but of a whole disk. That means they start with a bootloader and a partition table. First, you have to find out the offset of the partition and mount it with the offset option of mount.

fdisk -l /path/to/image

Fdisk shows the block-size and the start-block of the partition. Use them to calculate the offset. For instance, I have an image of a bootable stick with a 4GB FAT32 partition. The output of the fdisk command is:

Disk Stick.img: 3984 MB, 3984588800 bytes
249 heads, 6 sectors/track, 5209 cylinders, total 7782400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004bfaa

    Device Boot      Start         End      Blocks   Id  System
Stick.img1   *         128     8015999     4007936    b  W95 FAT32

So I have a block-size of 512 bytes and the start-block is 128. The offset is 512 * 128 = 65536. So the mount command would be

mount -o loop,offset=65536 Stick.img /mnt/tmp
computer_science/software/linux/commands/mount_.img_file.txt · Last modified: 2015/03/12 10:38 by thomas