-1

I have images of single paritions (not full disks) in vhdx format. I want to create VMs with Hyper-V with them. Since the images are only partitions the machines do not start.

How can I add the disk header or merge multiple vhdx partitions to a singe vhdx disk with header.

Notes: I have 2 use cases:

vhdx imags from WindowsServerBackup(/WindowsImageBackup) linux ext4 partition created with dd from lvm snapshot & converted with qemu-img I know the partition sizes since the source servers have to be running

1 Answer 1

0

If you have access to a linux machine, it's quite easy to solve.

Create a sparse file truncate -s 20GB file.img

Attach it to a loopback device losetup --find --show ~/file.img. This will return the name of the created loop device to the console.

Use fdisk/parted to create the partitions you need in the image via the loop device from the previous step.

Use dd to copy the contents of the image you have into the correct partition of the loop device

You might need to do some other work to make the image bootable, like installing grub or creating and populating the EFI volume. But that is an exercise for the reader.

Once that's all done, unmount any filesystems you mounted during this process and then use losteup --detach <loop device returned during creation>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .