XenServer VHD data recovery

data-recoveryvhdxenserver

I have the exported disk image of a VM from XenCenter in VHD format. I used compress from the settings, if that has any impact. How I can access the files without creating VM? I have the VM settings as well the disk. Fdisk can read the image but it does not lists any partitions. I don't care about the system itself, only the files. More notably /etc and /home.

VM was created in XenServer 6.2 (if I recall correctly) and it's using LVM. Later as I upgraded to Debian 8 I also upgraded XenServer to 6.5 and installed SP1. I must note that hard drive of XenXerver got corrupted but before doing the export guest OS worked without problems. I'm fairly positive the image I have is functional.

What I have tried so far:

  • Importing the VM into new master (different hardware). It failed to import. As it takes around 10 hours to do this, I'm not very keen to try this any more.
  • Importing the VM into old master (same hardware)
  • Importing the VM into new master (same hardware)
  • Converted VHD into VDI and mounted it to VirtualBox. It failed saying no bootable media found. Reason for convert is that VirtualBox didn't allow mounting VHD directly.
  • Tried to install new VM where I used virtualbox-fuse to mount it. But it sayd that VHD is in unknown format.
  • Tried to use losetup to pass boot sector of image and then mount it. But it can not find filesystem while mounting. At least ext4 or ext2.
  • Tried to attach VHD into Windows machine. It says it's either corrupted or unreadable.

There might be something else I have tried but I don't recall right now. I'm totally helpless right now.

Best Answer

you'll need a number of steps to mount & read the image. Firstly convert VHD to RAW

qemu-img convert -f vmdk -O raw myfile.vhd myfile.img

The original file will of course stay intact. Next you will have to mount the file. For this there are several steps involved

Firstly, connect the raw image to a loopback device.

losetup /dev/loop0 myfile.img

If I have understood correctly you are using a logical volume. This means you can't mount it directly but you find & active the volume group per

lvs

vgchange -ay YourVG

If lvs doesn't find your volume, you will have to change the lvm filter in

/etc/lvm/lvm.conf

and set it to

filter = [ "a/.*/" ]

with that done you can mount the logical volume.

mount /dev/mapper/lvol01 /mnt

Hope this was helpful.

Related Topic