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

Re: [Xen-users] mounting a filesystem image



-----BEGIN PGP SIGNED MESSAGE-----
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
/dev/loop1)

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.

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

iEYEARECAAYFAkrpi2EACgkQIA1+xqauveoCewCeJR0XbmipJgE+Ki6rAhRpCr6e
J40AnjvVyAgBXJ804FW1Puk/q5YBnrIU
=mr5e
-----END PGP SIGNATURE-----

_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.