Copy a Working Windows Hard Drive to a QEMU Image
QEMU is an open-source processor emulator used to run virtual machines in Linux variants. The QEMU convert function can convert other virtual machine formats to QEMU and vice versa. It can also convert a raw hard drive image to QEMU format. In order for it to work, the Windows hard drive in question must be available to Linux. If the Windows hard drive is not on the same computer, it can be removed and temporarily installed in an external USB enclosure. Plug that enclosure into the Linux computer while performing the conversion. The Windows partition will not be altered.
Instructions
1. Open a terminal window and type "su" to temporarily log in as the root administrative user. Users of Ubuntu, Debian and Debian variants should instead add "sudo" before each command.
2. Type "fdisk -l" to list the hard drives on the system. Look for an entry that says "Windows" in the "System" column.
3. Type the following command to convert the Windows drive to a raw image:
dd if=/dev/sdb2 of=/path/windows.img
Replace "sdb2" with the name of the Windows hard drive shown in the "fdisk" command. Replace "path" with the temporary location of the raw file. Be sure to use a location that has enough room.
4. Type the following command to convert the raw file:
qemu-img convert -f raw /path/windows.img -O qcow2 /path2/windows.qcow2
Replace "path" with the location of the Windows raw file. Replace "path2" with the directory you want to save the new image to. If it's the same location, be sure it has enough space for both full size images. This command converts the raw file to the QEMU native "qcow2" format. It can take a long time to finish running, up to an entire day for a 20 GB to 30 GB drive.
5. Type the following command to display a running status of the conversion:
watch -n 10 'du -h /path2/windows.qcow2'
Replace "path2" with the location of the QEMU image. The convert function does not provide status messages. The "watch" command runs the "du" command every 10 seconds and displays the file size of the "qcow2" image. Once the file is no longer growing, the conversion is finished. You can alter the time period by change "10" for the number of seconds you prefer.
6. Press the "Ctrl" and "C" keys to quit the "watch" command once the file stops growing. The QEMU image is ready for use.
Tags: following command, hard drive, Type following, Type following command, Windows hard, Windows hard drive, windows qcow2