Difference between revisions of "accessing a disk image in Linux"
(moved from Qemu on Linux) |
m (Accessing a disk image in Linux moved to accessing a disk image in Linux) |
(No difference)
|
Latest revision as of 13:43, 25 May 2006
Computing: Software: Linux: accessing a disk image
Instructions
In general, assuming the image file was made with the default disk head/sector parameters using qemu-img (in qemu) or bximage (in bochs):
sudo mount -o loop,offset=32256 /path/to/image /path/to/directory/
Specific example (Woozle's system):
sudo mount -o loop,offset=32256 /home/woozle/win98/c.img /mnt/qemu
The reason for the offset is that the image represents an entire disk; you can only mount a partition, not the entire disk. The offset is where the main partition starts. You can find out where partitions are in a disk image by using fdisk:
fdisk /path/to/image
Woozle example:
fdisk /home/woozle/win98/c.img
This takes you to a menu, where you type "p" to get a partition table:
Command (m for help): p Disk c.img: 0 MB, 0 bytes 64 heads, 63 sectors/track, 0 cylinders Units = cylinders of 4032 * 512 = 2064384 bytes Device Boot Start End Blocks Id System c.img1 * 1 520 1048288+ c W95 FAT32 (LBA)
Based on what I worked out below (which you don't need to read unless that sort of thing interests you), you work this equation to find the correct offset:
[Start] x [bytes-per-sector] x [sectors/track]
...where [bytes-per-sector] is the number after the "*" in "cylinders of..."
(Working backwards from the knowledge that 32256 – which was a Magic Number found by Tenebram – is the correct number, and trying to figure out why it is correct: If we presume that "sectors/track" means the number of sectors per track for a single head, then 4032 (which is 64 x 63) must be the number of sectors per track for all heads, and 512 is probably the sector size in bytes. The offset to a given sector, then (waving a magic wand at all this so that it matches reality somehow) is [start] x [bytes-per-sector] x [sectors-per-track] – which leads us to deduce that the units for the [start] number must be "tracks".)