[ARMedslack] qemu raw image partition offset calculation

Stuart Winter m-lists at biscuit.org.uk
Mon May 9 06:22:14 UTC 2011


Yep this is all good stuff.
ftp://ftp.armedslack.org/armedslack/armedslack-devtools/sheevaplug/qemu-to-sheeva.txt

I haven't digested everything you've put down but the above URL is how I
bootstrapped armedslack onto the sheevaplug -- converting a qemu
installation back to a bootable hard disk.

On Fri, 6 May 2011, Davide wrote:

> It's often handy to know the physical offset of the first partition of a qemu raw disk image.
> If you do not use raw images you can convert it to raw ... do what you need and convert it back.
> I've not yet found a reliable way of mounting non raw images from ordinary linux OS.
> You can use this trick to populate a qemu disk image with an armedslack miniroot sistem image directky from your linux x86 box.
>
> Unfortunatelly the offset depends on the geometry of the disk image.
> Here's how I guess the correct offset:
>
> the firs block of the firs partition is located in:
> the first sector of the second track
> it will be located in <sectors per track> * 512
>
> example:
> fdisk -l qemu_hdu.raw
> Disk qemu_hdu.raw: 0 MB, 0 bytes
> 5 heads, 54 sectors/track, 0 cylinders
> Units = cylinders of 270 * 512 = 138240 bytes
> Sector size (logical/physical): 512 bytes / 512 bytes
> I/O size (minimum/optimal): 512 bytes / 512 bytes
> Disk identifier: 0x00000000
>
>        Device Boot      Start         End      Blocks   Id  System
> qemu_hdu.raw1               1        1016      137133   83  Linux
>
> the firs partition of this image (qemu_hdu.raw1) will begin:
> (54 * 512) = 27648
>
>
>
> Ho do you go about creating the filesystem from the x86 linux box:
>
> What folows creates an ext2 filesystem on the first partition of the
> qemu raw disk image and subsequently mount is so that you can polulate it.
>
> # losetup -o <previously calculated offset> /dev/loop0  qemu_hdu.raw
> # mke2fs -b 4096 -i 16384 -m 1 -L surap_root /dev/loop0
> # mount /dev/loop0 /mnt/tmp/
>
> Hope this helps
> David
>
>
> _______________________________________________
> ARMedslack mailing list
> ARMedslack at lists.armedslack.org
> http://lists.armedslack.org/mailman/listinfo/armedslack
>

-- 
Stuart Winter
Slackware ARM: www.armedslack.org


More information about the ARMedslack mailing list