Imaging Windows 7

Imaging a physical disk for Windows 7 is very tricky as these operating systems tend to bind itself to the hardware system. Hence, you need to be extremely careful and execute the following pre-steps before running the main qemu-img instructions.


Keep in mind that the guide here requires a decent amount of understanding about Windows Operating System and QEMU knowledge.

PREPARE - From QEMU to Physical Disk

Recommended way to image the Windows 7 to physical disk and boot elsewhere. This is mainly because the virio drivers provided by Red Hat is very hard to install manually if we do it the other way round.


Step 1: Tidy Up

Make sure the operating system is at the condition where you want your user to see on first boot, with your software installed etc. Just tidy up to that point.

Step 2: Run Windows Sysprep

Next is to remove all the platform specific data. Windows 7 has a program packed inside its kernel called Sysprep. Run that program with administrator right.

> %WINDIR%\system32\sysprep\sysprep.exe

If you ran into sysprep related issue like out of count, you might want to refer to this page (please right click and open a new window):

Step 3: Generalize and OOBE

Once the GUI has opened, do the following:

  1. Select OOBE
  2. Check (enable) the "generalize" option (This is important!)
  3. Select "Shutdown" after sysprep

Then let the sysprep do the work. Once done, it will shutdown the operating system automatically. After that, you have a single shot sysprep ready Windows 7 ready for conversion. Follow the main page instruction.

PREPARE - From Physical Disk to QEMU

The most painful yet most commonly used direction. Usually, we do this for virtualizing old system carrying critical operational software but limited by hardware. This is not recommended for templating QEMU images for Windows 7.


Step 1: Tidy Up

Make sure the operating system is at the condition where you want your user to see on first boot, with your software installed etc. Just tidy up to that point.

Step 2: Uninstall Half-Baked Platform Specific Driver

If you are a developer and you're currently developing a platform specific driver (known as half-baked drivers), please uninstall them now. There is no telling that your half-baked driver will crush the boot up system. Otherwise, skip this step.

Step 3: Run Windows Sysprep

Next is to remove all the platform specific data. Windows 7 has a program packed inside its kernel called Sysprep. Run that program with administrator right.

> %WINDIR%\system32\sysprep\sysprep

If you ran into sysprep related issue like out of count, you might want to refer to this page (please right click and open a new window):

Step 4: Generalize and OOBE

Once the GUI has opened, do the following:

  1. Select OOBE
  2. Check (enable) the "generalize" option (This is important!)
  3. Select "Shutdown" after sysprep

Then let the sysprep do the work. Once done, it will shutdown the operating system automatically. After that, you have a single shot sysprep ready Windows 7 ready for conversion. Follow the main page instruction.

CLEANUP - After First Boot

After your successful imaging, boot up the Windows 7 QEMU image. You'll witness a different kind of welcome message and Windows will start to establish its platform specific parameters again. Let it done.

Create User Account

The OOBE boot will request you to create another user account, despite your existing one is still there. For this case, create it as a dummy account called "dummy" and provide no password. We're going to delete it anyway.

Imaging Windows 7 - Create User Account After OOBE

Login your Existing Account

Upon reaching the login page, login using your existing account. DO NOT login the dummy account for obvious reason.

Delete Dummy User Account

First thing to do is to delete the dummy account.

  1. Press START > Type "User Account"
  2. Select "Manage another account"
  3. Select the created "dummy" account
  4. Select "Delete Account" > "Delete Files" > "Yes" > "Yes" > ... (just clean delete that account already)
Imaging Windows 7 - Delete Dummy Account Step 1
Imaging Windows 7 - Delete Dummy Account Step 2 and Step 3
Imaging Windows 7 - Delete Dummy Account Step 4

Rearrange Your Shortcuts and Task Bar

If you notice, your task bar got reset to the initial condition, re-arrange the task bar to your initial condition. In this example, I cleansed all the Internet Explorer and place my Firefox back again.

Imaging Windows 7 - Rearranged Task Bar

Install QEMU Drivers

Proceed to install the QEMU drivers. You need them in order to operate properly in standard QEMU environment.

Restart 3 Times (optional)

You can now restart the operating system 3 times to ensure consistency. If all 3 times are working fine. You're good to go.

Activate Your Windows

OOBE removed your activated licenses during its clean up. You'll need to activate your Windows again based on Microsoft Licensing policy (e.g. standalone, and volume licenses should be working fine).

Snapshot Your Image (optional)

Now that your image is ready, it's always a good thing to do snapshot it as a base image. Once done, you're good to go!

That's all about Windows 7 operating system specific procedures.