1

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

7
  • 1
    I 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. Commented Apr 13, 2015 at 12:45
  • I don't have the image file yet... Commented Apr 13, 2015 at 12:48
  • You've tried the dd method, right? What are the results? Did you manage to get myfile.dd or myfile.vhd? Commented Apr 13, 2015 at 12:53
  • I got a myfile.dd which I converted to myfile.vhd - but it wouldn't book in VirtualBox... Commented Apr 13, 2015 at 13:06
  • 1
    You 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. Commented Apr 13, 2015 at 13:52

1 Answer 1

5

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 
5
  • If I zerofill first the disk via dd will the process go bit faster? I mean if disk is 40G it will take some time Commented Dec 31, 2020 at 17:13
  • Tip: 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. Commented Apr 2, 2021 at 13:36
  • How do I know on windows that my raw drive is PhysicalDrive2 ? Commented Jun 13, 2021 at 22:00
  • 1
    @felixyadomi you can use Get-PhysicalDisk on powershell to get the number. Commented Jun 27, 2021 at 16:39
  • On 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". Commented Dec 13, 2021 at 4:44

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.