Create a VHD file from a Linux disk
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
Related videos on Youtube
JezB
Updated on September 18, 2022Comments
-
JezB almost 2 years
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
-
Dmitry Grigoryev about 9 yearsI have done a similar thing with QEMU, and it worked. Do you still have the raw image file? If you have a machine with QEMU, you could try to boot your image in QEMU, and if that works, convert the image to vhd using
qemu-img
. -
JezB about 9 yearsI don't have the image file yet...
-
Dmitry Grigoryev about 9 yearsYou've tried the dd method, right? What are the results? Did you manage to get
myfile.dd
ormyfile.vhd
? -
JezB about 9 yearsI got a myfile.dd which I converted to myfile.vhd - but it wouldn't book in VirtualBox...
-
Dmitry Grigoryev about 9 yearsThat's why I ask if you can install QEMU. QEMU is able to boot from a device file (
qemu -hda /dev/sda
) or from a raw image (qemu -hda myfile.dd
). This way you could see at which point your system loses the ability to boot. -
JezB about 9 yearsQEMU is a Linux package - I need a Windows program...
-
Dmitry Grigoryev about 9 yearsYou won't have to run your virtual machine in QEMU all the time. Once you get it booting you will export the image to VHD format using
qemu-img
and (hopefully) run it in Virtual box on your Windows machine.
-
-
Dimitrios Desyllas over 3 yearsIf I zerofill first the disk via dd will the process go bit faster? I mean if disk is 40G it will take some time
-
md2k7 about 3 yearsTip: Convert to qcow2 first, then convert from qcow2 -> vhdx to compress away zeros. Before that, use zerofree to explicitly write zeros into an ext* filesystem.
-
felixyadomi about 3 yearsHow do I know on windows that my raw drive is PhysicalDrive2 ?
-
wbkang about 3 years@felixyadomi you can use
Get-PhysicalDisk
on powershell to get the number. -
W.Prins over 2 yearsOn Ubuntu (and presumably Debian), the linux package containing "qemu-img" is "qemu-utils" and therefore can be installed with the command "apt install qemu-utils".