Share via

Imaging Windows 2008 Server

Since I often need to quickly load Windows Server 2008 OS in my lab environment, I decided to invest some time into automating this procedure. In the process of doing so, I ran into some interesting challenges, hence this blog.


In my scenario, I would like to be able to create and restore an images of Windows 2008 server using my external USB drive. I wanted to use USB because most of the servers today support booting from USB and large USB external drivers are available at relatively low cost, also booting from USB is much faster and removes the need to waste a DVD. As much as possible I would like to automate the process, very useful when images large number of servers (ex. class room setup).

Required tools and prerequisites

  1. Windows Server DVD or ISO image.
  2. The Windows® Automated Installation Kit (AIK) for Windows® 7 installed on a machine where you will be performing some steps to create your bootable USB drive. In the rest of this guide I will refer to this machine as a technician computer. This machine should running Windows 7.
  3. External USB drive, with enough capacity to hold your images. Please, note that we will be formatting this drive, so ensure that you save your data first.
  4. Your server or workstation should be capable of booting from USB. Depending on your BIOS settings, you may have change the boot device order to allow your machine to boot from USB, or to interrupt the normal boot process by specifying a temporary boot device.

Creating a bootable USB drive

Instructions from this section are taken from Walkthrough: Create a Bootable Windows PE RAM Disk on a USB Flash Disk, I applied some slight modifications, based on my requirements. Specifically, the Technet documentation instructs you to format USB drive as FAT32, but this would prevent you from storing large image files on this media, due to FAT32 size limitations.

In this step, you create a required directory structure that supports building a Windows PE image.

  1. On your technician computer, click Start, point to All Programs, point to Windows AIK, right-click Deployment Tools Command Prompt, and then select Run as administrator.
    The menu shortcut opens a command-prompt window and automatically sets environment variables to point to all of the necessary tools. By default, all tools are installed at C:\Program Files\<kit>\Tools, where <kit> can be coWindows OPK or Windows AIK.

  2. At the command prompt, run the Copype.cmd script. The script requires two arguments: hardware architecture and destination location.

     copype.cmd <arch> <destination>

    where <arch> can be x86, amd64, or ia64 and <destination> is a path to local directory. For example,

     copype.cmd amd64 c:\winpe_amd64

    Running the script creates the following directory structure and copies all of the necessary files for that architecture. For example,




  3. Copy the base image (winpe.wim) into the c:\winpe_amd64\ISO\sources folder, and rename the file to boot.wim.

     copy c:\winpe_amd64\winpe.wim c:\winpe_amd64\ISO\sources\boot.wim

    4.   At a command prompt on the technician workstation attach the USB drive, use Diskpart to format the drive as NTFS spanning the entire drive, and set the partition as active. 

In order to be sure that you are about to format your USB driven and not any other drives, execute DETAIL DISK command after executing SELECT DISK 1.


The example above assumes Disk 1 is your USB drive.

select disk 1
create partition primary
select partition 1
format quick fs=ntfs

      6.  On your technician computer, copy all of the content in the \ISO directory onto your USB drive.

 xcopy C:\winpe_amd64\iso\*.* /e F:\

where C is the letter of your technician computer hard disk, and F is the letter of your USB drive.

Adding XImage utility to the WindowsPE image

1. Mount the boot image (boot.wim) using DISM tool to c:\winpe_amd64\mount. You need to perform this step from the Technician’s machine in the Windows Automated Deployment Kit command prompt.

Dism /Mount-WIM /WimFile:f:\sources\boot.wim /index:1 /MountDir:c:\winpe_amd64\mount


At this point if you switch to c:\winpe_amd64\mount directory you should be able to see the following directory structure


When WindowsPE image boots, it creates a RAM Disk and assigns letter X to it. The directories and files in this RAM will be loaded from boot.wim. By mounting this image we now have the ability to add additional files which will be available to us within WindowsPE environment.

2. Copy ImageX.exe from the Windows AIK tools directory into the system32 directory of the mounted WindowsPE image.

cd "Program Files\Windows AIK\Tools\amd64"

copy imagex.exe c:\winpe_amd64\mount\Windows\system32


3. Commit changes to the boot.wim and un-mount it. Prior to executing this step ensure that there is nothing that is using the c:\winpe_amd64\mount directory (ex. explorer or cmd ).

dism /unmount-Wim /MountDir:c:\winpe_amd64\mount /commit


Adding Bootrec utility the WindowsPE image.

I discovered that Boot Configuration Data (BCD) store needs to be rebuild in order to be made aware of the new partitions created as part of the image application process. This is a very straightforward operation if you have the right tool available. Such tool is bootrec.exe and it is part of Windows 7 or Windows 2008 RE (recovery environment). In this section we will make this tool available to us in the WindowsPE.

1. Insert Windows 2008 server DVD into technicians workstation.

2. Bootrec.exe and the DLLs it depends on are located in the boot.wim file on the Windows 2008 DVD in the sources folder


3. Mount boot.wim image from Windows 2008 DVD

Start Windows AIK Deployment Tools Command Prompt as an administrator and execute the following commands

Create directory structure into which to mount boot.wim

mkdir c:\WindowsServer2008

mkdir c:\WindowsServer2008\mount


Mount as read-only boot.wim

dism /mount-Wim /WimFile:d:\sources\boot.wim /index:1 /MountDir:c:\windowsServer2008\mount /readonly


4. Mount boot.wim of your WindowsPE (attach your USB drive before performing this operation)

The example below assumes that USB drive assigned letter F:

Dism /Mount-WIM /WimFile:f:\sources\boot.wim /index:1 /MountDir:c:\winpe_amd64\mount


5. Copy bootrec.exe and DLLs this utility depends on into WindowsPE image

Note that c:\WindowsServer2008\mount is the directory onto which we mounted mount.wim from Windows 2008 Sever DVD.

cd WindowsServer2008\mount\Windows\System32

copy BootRec.exe c:\winpe_amd64\mount\windows\System32

copy wer.dll c:\winpe_amd64\mount\windows\System32

cd en-us

copy BootRec.exe.mui c:\winpe_amd64\mount\windows\System32\en-US

copy wer.dll.mui c:\winpe_amd64\mount\windows\System32\en-US


We also need to copy localization files




6. Dismount images

Dismount and commit WindowsPE boot.wim image

C:\Program Files\Windows AIK\Tools\PETools>dism /unmount-WIM /MountDir:c:\winpe_amd64\mount /commit

Dismount boot.wim from Windows Server 2008 DVD

C:\Program Files\Windows AIK\Tools\PETools>dism /unmount-WIM /MountDir:c:\WindowsServer2008\mount /discard

Imaging your server

Now with this USB bootable drive in hand you are ready to proceed to imaging.

You can find the steps for capturing an image here.

Use this link to for instructions on how to apply the captured images. I found that I needed to utilize bootrec utility after applying my images in order to make my server bootable.

Execute the following command after applying your images with ImageX

bootrec /RebuildBcd

Bootrec will scan the available bootable partitions on your drive and add them to BCD.