Jump to content


Photo

Unable to mount a VHD in Dom0

Started by Romain Meillon , 25 January 2011 - 12:37 PM
2 replies to this topic

Romain Meillon Members

Romain Meillon
  • 2 posts

Posted 25 January 2011 - 12:37 PM

Hello,

I'm trying to mount a VHD in Dom0 but i does not find what's wrong in my process :

$ xe vm-disk-list uuid=1f29d3e2-6412-551a-45dd-9b386445c066
Disk 0 VBD:
uuid ( RO) : e5ff2e91-9b96-5794-c6a5-ae2c7a4985c4
vm-name-label ( RO): Debian Lenny 5.07 x86 Template v1.1 (1)
userdevice ( RW): 1

Disk 0 VDI:
uuid ( RO) : d64befa5-ebc9-4734-819c-4068eb395a66
name-label ( RW): Debian_Lenny_x86_root
sr-name-label ( RO): Local storage
virtual-size ( RO): 5368709120

Disk 1 VBD:
uuid ( RO) : aff02962-d301-2194-8f50-692e763a8651
vm-name-label ( RO): Debian Lenny 5.07 x86 Template v1.1 (1)
userdevice ( RW): 2

Disk 1 VDI:
uuid ( RO) : 17d2fa87-3690-433d-9d83-594970892412
name-label ( RW): Debian_Lenny_x86_swap
sr-name-label ( RO): Local storage
virtual-size ( RO): 1073741824

$ lvscan | grep d64befa5-ebc9-4734-819c-4068eb395a66
inactive '/dev/VG_XenStorage-27b4062d-3d1b-127f-f5f5-9d1f024d0724/VHD-d64befa5-ebc9-4734-819c-4068eb395a66' [5.02 GB] inherit

$ lvchange -a y /dev/VG_XenStorage-27b4062d-3d1b-127f-f5f5-9d1f024d0724/VHD-d64befa5-ebc9-4734-819c-4068eb395a66

$ ls -l /dev/mapper | grep 4068eb395a66
brw-rw---- 1 root disk 251, 7 Jan 25 12:55 VG_XenStorage--27b4062d--3d1b--127f--f5f5--9d1f024d0724-VHD--d64befa5--ebc9--4734--819c--4068eb395a66

$ kpartx -l /dev/VG_XenStorage-27b4062d-3d1b-127f-f5f5-9d1f024d0724/VHD-d64befa5-ebc9-4734-819c-4068eb395a66

Does not return anything, if i try

$ fdisk -l /dev/VG_XenStorage-27b4062d-3d1b-127f-f5f5-9d1f024d0724/VHD-d64befa5-ebc9-4734-819c-4068eb395a66

Disk /dev/VG_XenStorage-27b4062d-3d1b-127f-f5f5-9d1f024d0724/VHD-d64befa5-ebc9-4734-819c-4068eb395a66: 5385 MB, 5385486336 bytes
255 heads, 63 sectors/track, 654 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/VG_XenStorage-27b4062d-3d1b-127f-f5f5-9d1f024d0724/VHD-d64befa5-ebc9-4734-819c-4068eb395a66 doesn't contain a valid partition table

I also tried

$ losetup -o 4329472 /dev/loop5 /dev/VG_XenStorage-27b4062d-3d1b-127f-f5f5-9d1f024d0724/VHD-d64befa5-ebc9-4734-819c-4068eb395a66

$ fdisk -l /dev/loop5

Disk /dev/loop5: 5381 MB, 5381156864 bytes
255 heads, 63 sectors/track, 654 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/loop5 doesn't contain a valid partition table

I'm switching from XenSource to XenServer and does not use lvm everyday...

I followed some parts of this how-to

http://support.citrix.com/article/CTX117791

Can someone help me please ?

Thanks !!



Christoph Wegener Members

Christoph Wegener
  • 3,266 posts

Posted 26 January 2011 - 12:25 AM

losetup -o is direction to go.
However, you would need to calculate the correct offset depending on the VHD header size.
Check the VHD specs on microsoft.com for more information on how the VHD header is created.

Or you could just do a trial and error until you find a valid signature.
This script should give you an idea:

http://jim.studt.net/depository/index.php/converting-vhd-to-raw-disk-images-or-even-vmdk

for ((i=0 ; $i < 10000 ; i=$i + 1)) ; do
mount -o loop,offset=$(($i * 512)) </path/to/VDI> /mnt && break
done



Romain Meillon Members

Romain Meillon
  • 2 posts

Posted 11 October 2011 - 03:55 PM

Thanks a lot for your answer.

But, i'm back with this issue...

This loop doesn't seems to find the right offset to mount the partition...

Can the offset be larger than 5120000 (512 * 10000) ?

It's seems that i'm not the only one in this case as i saw this thread :

http://forums.citrix.com/thread.jspa?threadID=252142

Please note that i'm on a rescue system, not the xenserver system itself, but i've got access to LVs, in the same way than a real xenserver system.

Does this LVs are encrypted or something like that who can block any mounting process ?

Best regards,

Edited by: Romain Meillon on 11 oct. 2011 12:35