• Accessing data on xen lvm guest image

    Accessing xen guest image is very easy if the image is not lvm partitioned. But the main problem arise when the image is of lvm format and normal mount command cannot be used. Here I will show both the way. The first is when ext filesystem is used, and the second is when lvm is used.

    To mount xen guest image (without lvm)

    1. check the partition on the image
    # fdisk -lu
    The result will be something like this:

    2. Mount using offset option
    # mount -o loop,offset=106929152 /path/to/image /mnt
    where 106929152=208846*512, 208846 is the start of the partition. Using this way, you only mount the second partition and not the whole image

    3. You can now access your image at /mnt

    To mount xen guest image (with lvm)

    1. Check the partition on the image
    # fdisk -lu /path/to/image

    2. You have to install kpartx to handle lvm partiton
    # yum install kpartx

    3. Run kpartx on the image
    # kpartx -av /path/to/image

    4. Run vgscan to scan volume group available
    # vgscan

    5. Run vgchange to activate the volume group in the image
    # vgchange -ay VolGroup00

    6. Use lvs to see what is the name of your low volume group
    # lvs

    7. Mount the low volume group
    # mount /dev/VolGroup00/LogVol01 /mnt

    8. You can access your lvm image at the mounted directory which is /mnt

    9. To unmount it, a few commands have to be executed (umount for unmounting, vgchange -an to deactivate volume group, kpartx -d to delete device map and losetup -d to delete loop device used)
    # umount /mnt/
    # vgchange -an VolGroup00
    # kpartx -d /path/to/image
    # losetup -d /dev/loop0

    Hope this will be useful
    http://linuxwave.blogspot.com/2008/02/accessing-data-on-xen-lvm-guest-image.html

    Categories: Xen

    Comments are currently closed.