This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-users] mounting a filesystem image

To: geert Geurts <begeert@xxxxxxxxx>
Subject: Re: [Xen-users] mounting a filesystem image
From: Marcel van Dorp <M.vanDorp@xxxxxxx>
Date: Thu, 29 Oct 2009 13:32:33 +0100
Cc: xen-users@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 29 Oct 2009 05:33:19 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <db00b3d70910290420o69ff9a7fl573be19600255615@xxxxxxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
Organization: WiWo Support
References: <db00b3d70910290420o69ff9a7fl573be19600255615@xxxxxxxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla-Thunderbird (X11/20090706)
Hash: SHA1

geert Geurts wrote:
> Hello list,
> I'm a quit newby on xen, I'm studying  for CLP...
> I've got a domU setup and running without problems, I made a image using
> dd and formated after that using losetup to associate it to a loopdevice
> and than fdisk loopdevice to create two partitions on the image. So i've
> got /home/geert/xen/opensuse11/disk.img as my disk image, and it
> contains 2 partitions one swap device and one root partition.
> They function as axpected and I'm a happy man. Except for one problem...
> How can I mount the second partition on the host computer? I mean I can
> losetup -f /home/geert.../disk.img and then fdisk -l /dev/loop0 shows my
> two partitions but how can I access those partitions?
> Thanks!
> Greetings,
> Geert

part1: You need losetup with an offset to skip the partition table, and
part2: You need losetup with an offset to skip the first partition.

In short:

losetup the complete image (assuming /dev/loop0 as new device)

fdisk /dev/loop0

Write down #bytes per sector (usually 512)

option u to change units to sectors
option m to print the partition table

for each partition, write down Start and Blocks value

exit, and remove loop device

Calculate first offset = Start sector * sector size,
usually 63 * 512 = 32256

Now you can reconnect image on loop device, using the offset:

losetup -o 32256 /dev/loop0 binary.img

finally make a filesystem

mkfs -t ext3 -b1024 /dev/loop0 [#blocks of part1]

Repeat with values for second partition, and use another loop device (eg

losetup -o [offset2] /dev/loop1 binary.img
mkswap /dev/loop1 [#blocks of part2]

Finally you can mount the first partiton, and use 'swapon' for the
second partition.

That should do it.

Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


Xen-users mailing list

<Prev in Thread] Current Thread [Next in Thread>