Main menu:

Site search

April 2026
M D M D F S S
 12345
6789101112
13141516171819
20212223242526
27282930  

Categories

Tags

Restore Windows HVM on Xen with PartImage and kPartx

1. Shutdown Windows HVM
xm shutdown w2k8-VM1

2. Rename Windows HVM to keep current virtual machine state
lvrename /dev/xen-vms/W2k8-VM1 /dev/xen-vms/W2k8-VM1_Broken

3. Create new LVM Volume for Restore
lvcreate -n W2k8-VM1 –size 160g xen-vms

4. Change to backup directory
cd /backup/

5. Create Backupdirectory (cause cron job will create new image, so working image will not be overwritten)
mkdir /VM1

6. open Backupdir with image file of vm
cd W2k8-VM1

7. Move backuped file to backupdirectory
mv disk.mbr /backup/VM1
mv disk.sfdisk/backup/VM1
mv *img /backup/VM1
mv W2k8-VM1.cfg.old /backup/VM1

8. Restore Masterboot record
dd if=/backup/VM1/disk.mbr of=/dev/xen-vms/W2k8-VM1 bs=512 count=1

9. Restore Disk Geometry
sfdisk –force –no-reread /dev/xen-vms/W2k8-VM1 < /backup/VM1/disk.sfdisk

10. Mount Windows HVM
kpartx -av /dev/xen-vms/W2k8-VM1

11. Restore partitions of Windows HVM
partimage -e -b restore /dev/mapper/xen–vms-W2k8–VM1p1 /backup/VM1/Partition1.img
partimage -e -b restore /dev/mapper/xen–vms-W2k8–VM1p2 /backup/VM1/Partition2.img
partimage -e -b restore /dev/mapper/xen–vms-W2k8–VM1p3 /backup/VM1/Partition3.img

11. Unmount Windows HVM Partitions
kpartx -dv /dev/xen-vms/W2k8-VM1

12. Start Restored Windows HVM
xm create W2k8-VM1.cfg

13. Remove broken LVM Volume if VM is ok
lvremove /dev/xen-vms/W2k8-VM1_Broken

Write a comment