Steven's profileDevelopmentalBlogLists Tools Help

Blog


    30 September

    Developer Machine Builds for Real Men (and women) - WDS, WinPE, ImageX and Sysprep

    I like to rebuild my machine a lot. I usually install every beta under the sun, and my HDD is usually fragmented within a day of rebuild. So I need an efficient process around rebuilding my desktop and my laptop for developer use. Installing Vista Ultimate followed by Office, VS2005/2008, Sql 2005/2008, Visio, Project, Expression Suite, SysInternals, Reflector, Fiddler, Twhirl, Live Writer/MSN, Firefox, Opera; the list is endless. And these are my standard day to day tools.

    Enter WDS : Windows Deployment Services. Like most developers I have a Server 2008 license (either through TechNet, MSDN, or handed out at any user group these days!) and one of the 'Roles' is WDS. This software lets you specify a boot image and a build image to be deployed via the network. It operates with WIM files, which contain all the information to build a particular operating system and software.

    For example, if you load up your Vista or Windows Server DVDs, you will find a boot.wim and install.wim on those disks. Microsoft uses WIMs for deploying operating systems already, so the infrastructure is already here to build our own WIMs and deploy them. But instead of building a DVD, we'll deploy via a network so that any machine at home can be reimaged at any time.

    WinPE is a boot environment that gives us a command prompt. Generally WinPE is something you boot into, instead of your normal operating system. In fact, there is a boot.wim that contains WinPE, and its available in the Windows Assisted Installation Kit (WAIK) in x86 and x64 varieties.

    Sysprep is a tool build into Vista already. Usually hiding out at C:\Windows\System32\Sysprep, you can also hit it from the Vista Search prompt. It has a command line mode and a window mode. Sysprep performs a very interesting task. It will strip your current installation of all operating system logic such as language, domain, etc. This is known as the "Out of the box" experience (OOTB). If you run Sysprep and reboot, then you will be prompted for all the usual system information, time/date settings, etc. But once you fill those in, you will see your system still has all the programs installed, etc. All it does is "prep" the system for setup.

    Finally, ImageX is a command line tool used to image a machine and create a WIM file. Using this tool we can image a full installation and create an install.wim for our developer machine. Combined with Sysprep, we can create a WIM file that has been stripped of machine specific information.

    So how do we put it all together? Here's some steps around what I've done to give you an idea what's need to get this puppy rolling.

    A) Build your development machine with all the software you want. I found it easy to do this in a virtual machine; I was already using hyper-V on my 2008 server so this suited my needs. The cool thing here is that I've taken a snapshot after every software install, so in future if I want to build a machine with less software, I can just apply the relative image, then continue the steps below.

    B) Sysprep the machin with the OOTB experience, and shut it down

    C) On the machine running WDS, add the WinPE WIM as a boot image

    D) Also on WDS, create a new SHARE where we can put new image files. Make sure you have an account with full access to this folder; doesn't matter if it is password protected, we will see options to specify auth later.

    E) In the share folder, create sub folders called BIN and IMAGES. Copy the binaries from WAIK into the BIN folder (from C:\Program Files\Windows AIK\Tools\x86 or similar). Leave IMAGES empty; this is where we will put our developer image.

    E) Start up the developer machine again; it should detect your WDS and ask you to press F12 : press it!

    F) You will be prompted to choose a boot image. If you have more than one, ensure you choose the WinPE option. This will dump you at a command prompt eventually.

    G) We have to map a network drive to our share on the WDS server. For that we use 'net use' command:  net use z: \\server\share
    This will prompt for user and password. If you have any problems with the 'net' command, just try 'net /?' or 'net use /?'

    H) Time to image: go to Z:\BIN and you should see the files from before, including ImageX. Type this command: imagex /capture c: z:\images\install.wim "Vista Developer Machine" /verify
    This will capture the local C: to the images folder. If you want to image a different drive then feel free.

    WARNING: Be prepared to wait. Imaging takes a while, and the bigger your image/slower your network, the worse it gets. For me, it took about 24 hours, for a 18Gb image on my main network. Think about optimisations for this. For example, if you are imaging a VM and WDS is another VM on same machine, create a virtual network between the two. That way communication never leaves the host machine.

    I) Once imaged, you can close your developer VM. Go back to the WDS machine and add the new image file as an install image. You will also need to add another boot image since WinPE boot image will not boot to the installer. As mentioned earlier you can find boot.wim files on your Vista and Windows Server DVDs. I suggest the latter (which can be used to deploy Vista and Server 2008 images). Now you have a boot image and developer machine install image.

    J) Test it: provision a new VM (or host machine) and do the network boot thing again (F12). This time the Server 2008 boot image is an option, select it. Start following the prompts and you will eventually get an option to select an installation - Select your developer machine.

    WARNING: Be prepared to wait again! Once again, the imaging takes a while.

    K) After system finishes deploying you should have a full working developer machine!

    Further Notes

    The waiting times are somewhat annoying. Creating the machine image is something you really only have to do once, but you might want to automate it a little more to make it easier to deploy versions of a VM (snapshots) with a quick click of a button or PowerShell script. You could modify the WinPE boot.wim image to incorporate the ImageX tools, and a batch file so that you don't have to keep coming back to this article for reference. In fact, an autoexec.bat might even work bundled into your WinPE image.

    Building async in a separate VM can be slow but at least you can provide a nice structure for reusability, while still using your dev machine. Then leave it to reimage over a weekend or whatever when its needed. And you can obviously reimage multiple machines. WDS is great because you can also copy the install.wim files from Vista and Server across as well and deploy those if needed. Basically, no need for hard media any more. =)

    29 September

    DevSta Programming Competition Goes Live!

    Its Monday morning, just after 8am. The DevSta competition starts any minute now. 200 hours and 8 minutes to complete a Visual Studio 2008 project. The brief will be announced any second, and developers all over the country will start madly coding! For 200 hours, wives will be ignored, chores undone, children with no lift to school, washing up pile stacked up on the floor... society will be brought to its knees. Undoubtedly you've heard about the sub-prime market failure in the US? Hurricanes destroying cities? Countries in civil unrest? Its all in anticipation of what happens next, what happens in the next 200 hours.

    The combatants nervously await. The topic will be announced any moment. They glance at the clocks of the 3 machines humming nearby. They all report different time! A quick Google for "time" indicates that there are still a few precious seconds to go.

    Pressure in the bladder. Do I have time to go for #1? I deliberately built a toilet in my study for just this reason. A quick cost/benefit analysis indicates that its probably better to go now, because hospitals don't allow electronic equipment.

    Finally, the climax. A new email in the inbox from Microsoft... the topic is announced. It says to go to the website for the competition brief. Doing as asked reveals nothing though. Could the email have been sent 3 minutes too early? Could it be a cache issue? CTRL+F5 is repeatedly pressed about 100 times.

    The countdown clock on the website has ticked over! It now says 200 hours 8 minutes remaining. Yet there is no brief! Feeling like I'm falling behind already...

    In the end its the helping hand from a friend that reveals the PDF containing the brief.

    Game on!