Prepare a Virtual Environment for testing
by Mats Hellman on 14.May, 2010 under Windows, Windows Deployment
One of the more important tools I use in my day to day work is Virtual PC. To be honest I’ve been looking at VMware Workstation for a while because Virtual PC 2007 doesn’t support 64-bit guest operating systems. But that’s another story. Right now I manage with what I’ve got.
Why a virtual environment?
This might be the first question. Well it saves time and money. I can test different products and deployments without using a full expensive test lab. The virtual systems can’t replicate every possible scenario but I’ve managed fine so far.
You can’t test disk encryption and that’s to bad but almost anything else is possible without making changes to your production environment.
How to setup the environment
First of all you should create a few master images so you will be able to copy in servers and clients when you need new ones. This is simply done by installing a copy of Windows Server 2008, Windows 7 or any other system you might need in the future. I personally keep master images of
- Windows Server 2008 32-bit
- Windows Server 2003 R2 32-bit
- Windows 7 32-bit
- Windows XP Pro 32-bit
So if you need all of them you need to start installing. Just install the basic OS, install all/any tools you like to use. Maybe you even want install the Office suite. Another tool collection I suggest you install is the Sysinternals Suite. After you have installed all the basic Operating systems we need to Sysprep them so they can be used again and again without any collisions on SID:s etc.
Using Sysprep
After you have everything installed you need to sysprep your installation and let the guest operating system shut down so you can copy the virtual hard disk (.vhd) file. Sysprep has been integrated in Windows Vista and newer, XP and 2003 has the files on the installation media in the folder <DRIVE>:\Support\Tools\Deploy.cab . In Vista and newer you can find sysprep in the folder C:\Windows\System32\sysprep.
For Windows Server 2008 and Vista you need to install the Virtual Machine Addons to get it running smoothly and you really want them to be left alone by sysprep. After all we are running sysprep to get our master images for Virtual PC.
So to keep your Virtual Machine Additions in the image you need to create a sysprep.xml file in the sysprep folder. If you want to you can place anything in the Sysprep file but this is needed to keep the Virtual Machine additions for the next boot.
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
<settings pass="generalize">
<component name="Microsoft-Windows-PnpSysprep" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" processorArchitecture="x86">
<PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
</component>
</settings>
</unattend>
Once you have the file saved in the C:\Windows\System32\Sysprep directory just run from the command prompt.
sysprep /generalize /unattend:sysprep.xml
After the computer shuts down you can move the .vhd file to a storage directory and name it something like Ws2008-master.vhd.
Windows 7 has a greatly improved support to run as a virtual machine so I’ve never had to install any of the additions on a Windows 7 image.
The result
The next time you need to “install” a new virtual Server or client just copy the .vhd file to another location and rename it. Create a new virtual machine and point it to the newly copied .vhd file. Boot the server or client and you’re done. Easy, fast and great for testing.
Virtual PC wants to store everything in your home folder but I like to keep my virtual machines in the root of a drive. So I know where to find them.
D:\VMS to keep the vmc files
D:\VMS\VHD to keep the .vhd files in use, not the master images
D:\VMS\Master to keep the master .vhd files
D:\VMS\ISOS to store any ISO files I might need.
You should set it up the way you like it but for me that keeps it in order and I know where to look for my files.
If you have any questions feel free to comment and I’ll answer anything I can.
Setting up Windows Deployment services environment part 2
by Mats Hellman on 09.Jul, 2009 under Windows, Windows Deployment
Well it’s been a while now since I wrote the first article on this topic. I’m really sorry this blog has been quiet for quite some time now. The reason is quite simple. The early morning of May 11 I got the privilege to watch the birth of my daughter. Since that day everything else has been on a second place and not really important. I’ve returned from my father leave now so I’ll try to get the articles coming in a normal timetable again. Once again, sorry about the delay but the follow-up articles are being written right now.
In the last article we installed Windows Automated installation toolkit on the technician computer and setup a master installation and we used sysprep to prepare the computer for imagex.
In this article
We will create a WinPE image we can use imagex from to create and deploy our image to the Windows Deployment server. We will also modify our WinPE image to contain the drivers we need. Remember the latest WinPE is basically Windows Vista so when you download the drivers take that in consideration.
First of all download and extract the drivers you need. Make note on where your .inf files are located.
Using the WinPE command prompt
Since we already have our master installation it’s now time to start creating a WinPE CD to use for capture. If you want to save the image directly to your WDS server you need to include the network drivers in this image also.
Start up your WinPE command prompt. First and foremost we need to get an working PE directory so running the command
C:\Program Files\Windows AIK\Tools\PETools\
C:\Program Files\Windows AIK\Tools\PETools\..\x86
C:\Program Files\Windows AIK\Tools\PETools>copype.cmd x86 c:\winpe_x86
=================================================== Creating Windows PE customization working directory c:\winpe_x86 ===================================================
1 file(s) copied.
1 file(s) copied.
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\bcd
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\boot.sdi
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\bootfix.bin
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\etfsboot.com
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\fonts\chs_boot.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\fonts\cht_boot.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\fonts\jpn_boot.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\fonts\kor_boot.ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\boot\fonts\wgl4_boot.ttf
9 File(s) copied
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\bcd
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\fonts\chs_boot .ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\fonts\cht_boot .ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\fonts\jpn_boot .ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\fonts\kor_boot .ttf
C:\Program Files\Windows AIK\Tools\PETools\x86\EFI\microsoft\boot\fonts\wgl4_boo t.ttf
6 File(s) copied
1 file(s) copied.
1 file(s) copied.
Success Updating path to include peimg, cdimage, imagex
C:\Program Files\Windows AIK\Tools\PETools\ C:\Program Files\Windows AIK\Tools\PETools\..\x86
C:\winpe_x86>
Now that we have an PE folder on the drive we can modify it to contain programs we need. Like ImageX.
1 file(s) copied.
C:\winpe_x86>
Adding drivers to WinPE 2
Before creating the ISO image we can burn we need to add the drivers we need to the WIM image. You have your drivers downloaded right? If you need a network connection you’ll have to provide the network drivers. Note that you really don’t have to use the network, you can import the image to the master installation computers hard drive also and after you boot it up move it across the network (I use this if I forget to add drivers). Anyway this is how you add the drivers.
First of all let’s say, for simplicity, that your network drivers .inf files are located in C:\Drivers\Network\WinALL\ and your WinPE .wim image as above in C:\WinPE_X86\winpe.wim. What you need to do first of all is mount the wim image to get it in read/write state so here is how you do it
C:\Program Files\Windows AIK\Tools\PETools>peimg /inf="C:\Drivers\Network\Winall\*.inf" c:\winpe_x86\mount
C:\Program Files\Windows AIK\Tools\PETools>imagex /unmount /commit C:\winpe_x86\mount
To explain what’s going on above
- Mount the wim image read/write to the mount folder in C:\winpe_x86
- Use peimg to add the needed network drivers ( you can continue with chipsets a.s.o if you need to )
- unmount the wim image and commit the changes made.
Once that’s done we need to create our ISO image. So back to the terminal and run the following to create a ISO file using the winpe.wim and the content of the ISO folder.
C:\Program Files\Windows AIK\Tools\PETools>oscdimg -n -bc:\winpe_x86\etfsboot.co
m c:\winpe_x86\ISO c:\winpe_x86\winpe_x86.iso
OSCDIMG 2.54 CD-ROM and DVD-ROM Premastering Utility
Copyright (C) Microsoft, 1993-2007. All rights reserved.
Licensed only for producing Microsoft authorized content.
Scanning source tree
Scanning source tree complete (18 files in 8 directories)
Computing directory information complete
Image file is 211216384 bytes
Writing 18 files in 8 directories to c:\winpe_x86\winpe_x86.iso
100% complete
Final image file is 211216384 bytes
Done.
C:\Program Files\Windows AIK\Tools\PETools>
Now you have a ISO file you can burn to a CD and boot from, the CD contains ImageX and the necessary drivers.
Follow Up
What we have done in this article is creating an WinPE 2 disk to use for capture, we added some drivers for networking and possibly chipsets to our image so it will recognize the hardware.
In the next article of this series we will capture our master image and import it to Windows Deployment server. Hope to see you next week when the series continues.
Setting up a Windows Deployment Services environment
by Mats Hellman on 23.Mar, 2009 under Windows, Windows Deployment, XP Professional
Windows deployment services was released to replace the old Windows RIP. Windows Deployment Services (WDS) makes it easier for us to deploy Windows Vista or even Windows XP using images. In this article I will go trough some of the steps I had to do to get everything up and working. For someone using Microsoft only environment this should be a very straightforward process but we run DHCP on Linux servers and have quite a mixed environment so there where some things to consider.
What you need
- Technician computer (your desktop/laptop)
- Master computer (the computer from which the image will be captured)
- Client computer (In the example this is the same as the master computer)
- Windows Deployment services configured and running on a server.
- DHCP server in the network.
First of all install Windows Automated Installation Toolkit to your technician computer. You will need it to modify the WindowsPE image we use to capture the .wim image.
Creating and imaging an Master Installation
First and foremost you need to have a Master installation. This will be the starting point for any of the deployments you will do so think carefully about what you want to install on this machine. Because we still deploy Windows XP Professional 32-bit this is what this article will cover. At some point I will make a Vista image article but let’s save it for later as the process is almost the same.
Things I want to install are Microsoft Office and programs that we don’t deploy normally trough group policies or other central management systems. I also like to change the OEM information on our installations, like adding the company logo at the Computer information page and information on how to get in contact with our support. So if you have a logo in some format save it as oemlogo.bmp and create oeminfo.ini file. In the oeminfo.ini add the following lines
[general]
Manufacturer=Your Company name
[Support Information]
Line1=For technical support call
Line2=123-456-789
Line3=http://www.nixadmins.net/
Of course change the settings to match your own company. Done customizing? Let’s get on to generalizing the computer.
Using Sysprep to prepare the computer to be imaged.
To remove anything that identifies this computer we need to run sysprep on it. If you are installing Windows XP Professional Service Pack 3 from your Volume License media slip it in and go to SupportTools. In the folder you’ll find Deploy.cab. Extract sysprep.exe,setupcl.exe to C:Sysprep. Also copy the I386 folder from the CD to C:I386, we will need it if we want any kind of regional settings applied to the installation. While we are at it extract the setupmgr.exe to your technician computer, this step is optional but it speeds up creating the Sysprep.inf file quite a bit. Done?
Start up setupmgr.exe on your Technician Computer and select Create New and Sysprep setup file, select Windows XP Professional. Select fully automated and start filling in blanks, fill in the local administrator password also, you can encrypt it and the sysprep folder will be deleted from the target computer once the image is done. We won’t make this installation fully automated (even if we chose that option, but you still can) because I want to keep our company naming policy on the computers. So after filling in your volume license key and owner information save the sysprep.inf file somewhere and open it for editing. Your file should look something like this.
;SetupMgrTag
[Unattended]
OemSkipEula = Yes
DriverSigningPolicy=Ignore
ExtendOemPartition=1
InstallFilesPath=C:i386
TargetPath=WINDOWS[GuiUnattended]
AdminPassword=A lot of bla bla.
AutoLogon=Yes
AutoLogonCount=3
OemSkipRegional=1
OemSkipWelcome=1
TimeZone=125
EncryptedAdminPassword=Yes[UserData]
OrgName=”Your company name”
ProductKey=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
FullName=”IT Department”
;ComputerName=* ;<- Notice I commented this line out to make the Mini installer ask for a computer name.[RegionalSettings]
LanguageGroup=1
Language=0000081d[Sysprep]
BuildMassStorageSection=Yes[TapiLocation]
CountryCode=358
Dialing=Tone
AreaCode=09[Branding]
BrandIEUsingUnattended=Yes[Proxy]
Proxy_Enable=0
Use_Same_Proxy=0[Identification]
JoinDomain=domain.com[Networking]
InstallDefaultComponents=Yes
Compare your file with the one above. That’s how it should look like. After you are done with the file copy it over to the same folder you placed sysprep.exe on the master installation. Which should be in C:Sysprep. Once that is done let’s prepare the computer for ImageX.
Open the command line (cmd.exe) and go to the C:sysprep folder. In the folder run
. The switch mini stands for mini setup which will be called once the computer reboots, it will use the sysprep.inf file to fill in as many of the blanks as possible. So if you are using a file like mine it should ask only for a computer name. The reseal switch clears Event Viewer and prepares the computer for delivery, it also sets the mini setup to start at boot up. Once Sysprep is done the computer will shutdown.
Follow up
So what have we done so far?
- Set up the Technician computer with Windows Automated Installation toolkit and setupmgr.exe.
- Created a master installation to use as a base for our future images.
- Used sysprep to prepare the computer for ImageX.
In the next article I’ll go trough setting up a custom WinPE image to use to capture our current master installation using ImageX and using it to capture the .wim image to our Windows Deployment server. So I hope to see you in a few days once the next part of this article is done.

