[CentOS] Mount a Xen disk image file

Dirk H. Schulz dirk.schulz at kinzesberg.de
Thu Aug 7 13:32:19 UTC 2008

Hi Folks,

I search for a way to mount the .img files virt-install creates for Xen 
VMs. Using fdisk -lu I found it contains to 2 partitions:

> # fdisk -lu /var/lib/xen/images/BaseCentos.img
> last_lba(): I don't know how to handle files with mode 81ed
> Sie müssen angeben Zylinder.
> Sie können dies im Zusatzfunktionsmenü tun.
> Platte /var/lib/xen/images/BaseCentos.img: 0 MByte, 0 Byte
> 255 heads, 63 sectors/track, 0 cylinders, zusammen 0 Sektoren
> Einheiten = Sektoren von 1 × 512 = 512 Bytes
>   Gerät  boot.     Anfang        Ende Blöcke   Id  System
> /var/lib/xen/images/BaseCentos.img1   *          63      208844 
104391   83  Linux
> /var/lib/xen/images/BaseCentos.img2          208845     8177084 
3984120   8e  Linux LVM

And I can mount the first partition with no problem using the offset 
(start) from the partition table:
> mount -o loop,offset=$((63*512) /PATH/TO/IMAGE.img /MOUNTPOINT
But I cannot mount the second partition using the offset of it:
> mount -o loop,offset=$((208845*512)) /PATH/TO/IMAGE.img /MOUNTPOINT
> mount: you have to specify the file system type
Even using ext3, ext2 does not work. I do not think the offset is incorrect 
- I venture it is because the second partition is LVM (8e).

Did anybody out there succeed in mounting an LVM partition out of an image 

Any hint or help is appreciated.


More information about the CentOS mailing list