[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Accessing directly the qemu filesystem



>> % nice -19 qemu -hda hda.img -user-net -boot d -cdrom sarge-i386-1.iso
>> Is there anyway to access directly the "hda.img" image from the host
>> system?
> Yes, you can use a loop device (as you would do to mount a file
> containing a cdrom iso image) with the appropriate offset (see the
> losetup command). The partition table and some basic math should tell
> you the right value for the offset.

Thank you! Counting the appropriate offset was not so obvious. After
googling here and there, finally I found the right offset values.
This is my disk image:
--------------------------------------------------------
Disk /dev/loop0: 3645 MB, 3645440000 bytes
255 heads, 63 sectors/track, 443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot  Start  End   Blocks  Id  System
/dev/loop0p1     1  267  2144646  83  Linux
/dev/loop0p2   268  401  1076355  83  Linux
/dev/loop0p3   402  443   337365  82  Linux swap/Solaris
--------------------------------------------------------

The first  partition offset is 32256 (63 sectors @ 512 bytes)
because the partition table is at first track. Therefore,
# losetup -o 32256 /dev/loop1 hda.img
# mount   -t ext3  /dev/loop1 /first_partition

The second partition offset is 2196149760 (267 cyl * 8225280)
because it is 267 cylinders after the first partition. Therefore,
# losetup -o 2196149760 /dev/loop2 hda.img
# mount   -t ext3       /dev/loop2 /second_partition

regards,

-- 
Rahmat M.  Samik-Ibrahim -- vLSM.org  -- http://rms46.vLSM.org/ --
Fetch my GNUPG public key at http://rms46.vlsm.org/pgp/pub.txt ---


Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: