Linux – Create a VHD file from a Linux disk

ddlinuxvhdvirtualbox

I have a disk containing CentOS 5.8 that was removed from a dead box. I would like to make a VHD file from this disk so I can run a virtual machine (instead of a new physical machine).

The Virtual Machine host is a Windows 2008 Server running VM Virtual Box.

I can't use disk2vhd (because this is a Windows program & Windows cannot 'see' the volume (it's attached by a USB adapter & the disk is visible in Disk Management)

I've tried the dd method specified in https://superuser.com/questions/410940/how-to-create-vhd-disk-image-from-a-linux-live-system, but the VHD's don't boot once created.

Does anyone have any ideas?

Thanks

Best Answer

You wrote that "QEMU is a Linux package", but is not fully true anymore. One example of build of QEMU for Windows is as part of WinSetupFromUSB 1.8 program.

The other build of QEMU is in qemu-img for Windows.

The third build of QEMU is as mingw-w64-x86_64-qemu package.

Convert in Windows a RAW PhysicalDrive2 to VHD

qemu-img.exe convert -f raw -O vpc \\.\PhysicalDrive2 CentOS-5-8.vhd

Convert in Linux a RAW sdb to QCOW2

qemu-img convert -f raw -O qcow2 /dev/sdb fitsu_MKB3021LT.qcow2

Convert a QCOW2, RAW, VMDK or VDI image to VHDX

qemu-img.exe convert source.img -O vhdx -o subformat=dynamic dest.vhdx

Convert a QCOW2, RAW, VMDK or VDI image to VHD

qemu-img.exe convert source.img -O vpc -o subformat=dynamic dest.vhd