Troubleshooting KVM Boot Stuck at “Booting from Hard Disk” After Hyper-V VHDX to QCOW2 Conversion


3 views

The problem occurs when migrating a Hyper-V VHDX disk (originally from Ubuntu Server 16.04) to KVM's QCOW2 format. The VM hangs indefinitely at the "Booting from Hard Disk" message during startup. This is particularly common when:

  • The original VM didn't have GRUB installed
  • Disk geometry or boot sector wasn't properly preserved during conversion
  • KVM's virtual hardware differs significantly from Hyper-V's configuration

First verify the disk status using qemu-img:

qemu-img info converted_disk.qcow2

Check if the disk is recognized as bootable:

file -s converted_disk.qcow2

Boot from a live ISO and chroot into the system:

sudo mount /dev/vda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt

Then install/reinstall GRUB:

grub-install /dev/vda
update-grub

Instead of direct conversion, try this workflow:

qemu-img convert -f vhdx -O raw source.vhdx intermediate.raw
qemu-img convert -f raw -O qcow2 intermediate.raw final.qcow2

Add boot parameter explicitly when creating the VM:

virt-install --name ubuntu-vm \
--memory 2048 \
--disk path=final.qcow2,format=qcow2,bus=virtio \
--boot hd

For non-GRUB systems, create a bootable ISO with custom loader:

mkdir -p /tmp/boot/grub
cat > /tmp/boot/grub/grub.cfg << EOF
set root=(hd0)
linux /boot/vmlinuz root=/dev/vda1
initrd /boot/initrd.img
boot
EOF
grub-mkrescue -o bootloader.iso /tmp/boot

Attach this ISO as secondary boot device.

Add these to your kernel command line if you can access GRUB:

console=ttyS0,115200n8 earlyprintk=serial
rootdelay=90

For deeper diagnostics:

qemu-system-x86_64 -enable-kvm \
-drive file=converted_disk.qcow2,format=qcow2 \
-serial stdio \
-monitor telnet:127.0.0.1:55555,server,nowait \
-D qemu.log -d int,cpu_reset

Then connect to QEMU monitor:

telnet localhost 55555
info registers
info block

When migrating virtual machines from Hyper-V's VHDX format to KVM's QCOW2, boot issues frequently occur if the original VM didn't use GRUB. The "Booting from Hard Disk" hang typically indicates missing or misconfigured boot components in the converted image.

First verify the disk structure using qemu-img:

qemu-img info converted_image.qcow2
qemu-img check converted_image.qcow2

For BIOS boot issues, examine the Master Boot Record:

sudo apt-get install mtools
msdosfsck -l /dev/kvm_volume

Option 1: Chroot repair using a live CD:

sudo mount /dev/vda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
apt-get install --reinstall grub-pc
grub-install /dev/vda
update-grub

Option 2: Direct GRUB installation via rescue mode:

grub-install --boot-directory=/boot /dev/vda
grub-mkconfig -o /boot/grub/grub.cfg

Ensure your libvirt XML contains proper boot settings:

<os>
  <type arch='x86_64' machine='pc-i440fx-2.9'>hvm</type>
  <boot dev='hd'/>
  <bootmenu enable='yes'/>
</os>

For non-GRUB systems, try booting directly from kernel:

<os>
  <kernel>/var/lib/libvirt/images/vmlinuz-4.4.0-142-generic</kernel>
  <initrd>/var/lib/libvirt/images/initrd.img-4.4.0-142-generic</initrd>
  <cmdline>root=/dev/vda1</cmdline>
</os>

When converting VHDX to QCOW2, include bootloader preservation:

qemu-img convert -p -O qcow2 source.vhdx target.qcow2 -B /path/to/original_boot_sector