We want to take a look at the end to end creation of a .wim image and the deployment of this image via Windows Deployment Services.
This will require several key components to be in place for your environment.
- Microsoft Windows AIK – Windows 7, Server 2008
- A master workstation that you wish to clone
- A Server to host Windows Deployment Services
- Network infrastructure to accomplish the network copy and supply other services between the server and workstation
The first step on the front end of our deployment process is to create the Windows PE environment that will serve to boot the workstation into the PE environment as well as partition the drives via diskpart, copy the .wim image down to the drive, apply the image, copy the boot files that Windows 7 expects to the partition and then booting the machine into its sysprep stage of installing.
In order to accomplish the above mentioned tasks, we need to have the Windows Automate Installation Kit installed which provides the tools to create and customize .wim images which is a requirement for this process.
Using the Microsoft Windows AIK
After you have installed the Windows AIK toolkit, you will need to prepare your Windows PE environment which will be used later to boot from WDS. We will need to run the copyPE command from the Deployment Tools Command Prompt which is found under your Microsoft Windows AIK program group under Programs.
Notice above that if you leave out the architecture of the pe files, it will give you an error and remind you that you need to specify which type of architecture you are wanting to deploy. You also need to specify the directory that you want the PE files to be stored in. In the example above, we are copying the files to the c:\pebuild directory.
By using the Windows Automated Installation Kit we can create a custom Windows PE environment that allows us to prepare the drive with various partitioning tools, establish network connectivity to map network shares and so forth, copy images down, and actually restore the image to the drive once it is prepared. We will show you how you can use this to create and choose from any number of custom images.
- After running the copype command, your directory will look similar to the following:
The file that is in the root directory of the copye directory we created with the WAIK tools called winpe.wim….we will use this file as our boot image for our Windows PE environment.
- Move the “winpe.wim” file to the .ISOsources directory and rename it something like boot.wim
We need to mount this image above and make a couple of changes. To mount the above image to modify its contents we need to utilize the imagex command found in the deployment tools command prompt.
- In your programs folder, navigate to Microsoft AIK and launch the Deployment tools Command Prompt. Note this is the same command prompt we used to run the copype command.
- Create a folder on the root of your CDRIVE and call it something like mount. The name of this folder is not significant other than we need to know what it is called before we can use the
- Run the following command from your deployment command prompt: imagex /mountrw c:\copype\sources\iso\boot.wim 1 c:\mount
*Note* The path above is relative based on your folder names that you chose to create. - Navigate to the c:mount directory and Windows …..create a Tools folder
- Copy the imagex command found in C:\Program Files\Windows AIK\Tools\x86 folder and copy the imagex command to your c:mountwindowstools folder. Navigate to your host workstation’s c:windowssystem32 folder and copy the shutdown.exe file to the c:\mount\windows\tools directory. We will call on these tools in a startup script we will configure next.
- Also contained in the .tools folder are a couple of files that we create. One is a batch file that is the work horse of the PE process. It will map a network drive, copy down the image file, partition the drives as we want them, apply the image file, copy boot files, and then reboot the workstation. The other text file we will create is passed into the diskpart utility to tell it how to partition the drives so we don’t get prompted for user input. We will call one file clean.bat and the other clean.txt ….however, these can be called anything.
Clean.bat Contents:
net use z: \\fileserver.somedomain.com\yourshare /user:domain\user password
diskpart /s clean.txt
copy z:\yourimage.wim n:
imagex /apply n:\yourimage.wim 1 n:
bcdboot.exe n:\Windows
del /Q n:\yourimage.wim
shutdown -r -t 0
GOTO:EXIT
:EXIT
Clean.txt Contents:
| select disk 0 clean create partition primary size=200 select partition 1 format fs=ntfs quick label=”system” assign letter=c active create partition primary select partition 2 format fs=ntfs label=”Windows” quick assign letter=n |
Image Prerequisites:
The above files depend on having a .wim image to actually deploy. So in the file above, yourimage.wim is your .wim image that you have already created. We will cover this topic in another post, but for now we will assume that you already have a .wim image of a Windows 7 operating system you are wanting to deploy.
Last Piece to the Mounted boot.wim:
The final thing that we need to do with the mounted boot.wim image that we will be deploying via WDS is to add the clean.bat batch file to the startnet.cmd file that is contained in the c:\mount\windows directory…..edit that file and you will see that it only contains one entry called wpeinit which is used to start up network services in the PE environment. Edit your startnet.cmd file to contain the following:
wpeinit
cd /d %systemdrive%\windowstools
clean.bat
So once the PE environment starts, it will initialize the network services, change to our tools directory that we created, and then initiate the clean.bat file that will do the work.
Closing up the mounted directory:
Now that we have all the elements of the PE environment in place, we can close up the mounted wim image and let it do its cleanup. To unmount the directory we need to issue the following command:
imagex /unmount /commit c:\mount
The imagex command will commit the changes and cleanup the mounted directory. All changes will be saved back into the boot.wim file that we had mounted earlier.
Installing Windows Deployment Services
To install WDS….navigate on your deployment server to the “Server Manager” snapin under your “Administrative Tools” group.
- Expand your “Roles”
- Click on “Add Roles”
- Select “Windows Deployment Services”
The above screenshots show the steps/screens from installing the Windows Deployment Services component to our server. Now we need to configure WDS to serve out the boot image that we want.
Configuring WDS
You will find Windows Deployment Services under Administrative Tools. You will have to right-click on “Servers” and then click “Add Server” to add your “local host” server to the console.
Right-click your server name and select “Configure Server” once the server is added to the console
Configuring WDS to serve out the boot image:
Once you click the configure server you will see the following screens…..click Next….
You will be asked to enter the path for your remote install directory…***Note if you leave the C: drive and your system is installed here, you will receive a warning that this is not recommended….however, it will allow you to proceed.
The next screen allows you to choose how you want the server to respond to hosts – known and unknown
Install begins:
The final screen is the “Operation Complete” screen. It will ask you if you want to add images to the server now. You can uncheck this box and add your images later.
After you finish, we want to add a “boot image” to the server….to do that…right click on the “boot images” folder and click “add Boot Image”
You will be asked for the location of your “Image File”
You will be asked to browse to your file. We need to have the file “boot.wim” that we created in the initial steps handy to provide to WDS. You will need to copy the file to your WDS server if you have the WAIK installed on a separate server or workstation.
After you select your image…it should display the path in the “File Location” box
You will be asked to provide a name for your image. ***Note that the Image Name is also the name that is presented to the PXE clients boot screen
The summary screen will show you the image name and file location summary:
The operation should finish quickly once you press “Next”
You should see the image shown in the Boot Images screen in your WDS console:
Please note that the firewall is turned on by default. It is recommended that you turn your firewall off on your WDS server as this can cause issues with WDS and client requests:
Also of note on your WDS server, if you are running WDS on the same machine that you have DHCP installed on, you need to change a couple of options in WDS for the two services to coexist. Click on your WDS server in the WDS console and select “Properties.” On the “DHCP” tab, check both boxes per the explanation to coexist both services:
Now that we are all set with WDS, it is time to start booting clients! Set your PXE boot to the top of the list, or manually force PXE with an F12 key press, etc. You will then see the prompt for PXE WDS boot. By default it is set to prompt you for another F12 key press:
Of note, if you have only one image, you will simply see the boot files start to copy over. However, if you have added more than one boot image, you will be prompted to choose between your boot images:
You should start to see the boot image loading:
After the boot.wim finishes loading, you will be booted into a PE environment where your batch file we created earlier, “clean.bat” should start to map your network drive, partition your hard drive, copy down the image, and then apply the image.
Popularity: 60% [?]






























Recent Comments