Score:0

Add Partition Table to existing vhdx partition image

br flag

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:

  1. vhdx imags from WindowsServerBackup(/WindowsImageBackup)
  2. 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

Score:1
gu flag

Not authoritative but the answer to your question I think is, it depends on whether the original system disk was mbr or gpt. For windows I think you have to add the boot partition before the data position, make the disk bootable with (MBR disk) fixmbr and fixboot and possibly make the partition active (via diskpart), or fir GPT and UEFI, recreate the EFI and MSR partition. I think this article explains all for UEFI: http://woshub.com/how-to-repair-deleted-efi-partition-in-windows-7/

Alt Option 1: You might get away with a fresh Windows install on a vhd, then delete the windows partition, add the partition-only disk, and repair the boot process (startup repair)...

Alt Option 2: A bit of a workaround rather than a direct answer... Maybe, I can't remember if I've successfully tried it, but maybe ...

Create a new vhdx attached to a VM, do a basic Windows install on it, then shut down and attach the partition-only vhdx as an additional disk, then boot into gparted or your other favorite recovery iso tool (Hirens 64?), And copy (clone) the partition over the top of the existing partition.

You might then have some boot issues to resolve, in Windows setup boot > repair > command prompt, with bcdedit.

Alt Option 3: You could alternatively use the command line wbadmin tool via winsetup > repair to restore the Windows backup, if it was a system image backup. There's pre-reqs to meet such as you need the same number of 'physical' disks to restore to (attached vhds, if it's in a VM) with the same or larger capacity than the original disk - even if it was an 8TB disk with only 1MB in use, you'd need a >8TB virtual disk to restore into.

Don't forget to check boot order in hyper-v as you change disks around and repair things; you might fool yourself that you haven't fixed it because of an incorrect boot order.

I'm not sure about Linux, but for windows you will also want to match the VM generation to the original system type - i.e. in hyper-v, generation 1 VM for pre-UEFI boot (a traditional bios based system), and generation 2 VMs for UEFI boot systems.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.