Converting a Physical disk to a Virtual disk with Qemu’s qemu-img on Windows

Just because even I forget from time to time.

You need to do this as administrator, even better if the disk doesn’t have a drive letter or mounted in any way under Windows.

Fujitsu MPB3021AT

In my case I picked up a 486SX with an aging Fujitsu disk.

qemu-img.exe convert -f raw -O qcow2 \\.\PhysicalDrive2 fujitsu_MPB3021AT.qcow2

And as fast as your machine can read the disk, you’ll have your Qcow2 disk image. As of Qemu 2.9.0 the formats include:

  • blkdebug
  • blkreplay
  • blkverify
  • bochs
  • cloop
  • dmg
  • luks
  • nbd
  • null-aio
  • null-co
  • parallels
  • qcow
  • qcow2
  • qed
  • quorum
  • raw
  • replication
  • sheepdog
  • vdi
  • vhdx
  • vmdk
  • vpc
  • vvfat

Which is quite a list.  Obviously since I’m reading a physical disk, the format is RAW.  I just output it to Qemu for my personal ease.

Also once the image was created I could quickly run it under Qemu, and discover that yes this was a machine running Windows 95.

qemu-system-i386.exe -hda fujitsu_MPB3021AT.qcow2 -soundhw es1370 -vga cirrus

So there you go from a “dead system” to at least fully recovered data in minutes.  KVM may get all the pres excited but it’s nothing without the awesome support of Qemu!

5 thoughts on “Converting a Physical disk to a Virtual disk with Qemu’s qemu-img on Windows

  1. Excellent tip! I’ve just used this to make an image of a FreeBSD_4.7 on a flaky 2.5″ 540MB Western Digital drive. Next step is to attempt to move the image to a Compact Flash card so I can carry on using it with real hardware.

    • That will be the real trick. But in a worst case, you can now do a dump/restore if it’s not too happy, at least preserving the contents

      • Seems to be a problem writing back the the CF disk. The CF card is mounted in a CF-ATA converter and ATA-USB converter so W10 sees it as a real drive. When I try to FDISK and write out the boot sector I just see lots of “hard error writing to fsbn” messages.


        qemu-system-i386 -drive file=WD540MB.qcow2 -drive format=raw,media=disk,file=\\.\PhysicalDrive1

        • Some USB stuff seems to aggressively protect the first 512 bytes of disks, preventing stuff like partitioning and whatnot.

          I’m not sure of what the exact issues are, but generally run it as administrator, and bring up disk manager and make sure no volumes are mounted. You may even have to “eject or dismount” the disk from disk manager… Not the dock icon.

          • I made an image of the CF card and worked with that but still had some problems with fdisk and disklabel. Then I tried Qemu with -M isapc and it worked. Made a minimal installation and transferred everything across with dump/restore.

            Next step is to see if I can write it back to the CF and get it to boot on real hardware.

Leave a Reply

Your email address will not be published. Required fields are marked *