Monday, 1 December 2008

Compressing the WinPe PXE boot image

The next way to speed up the TFTP download time of your PXE image is to reduce its size. This can be achieved by compressing it -a tip which came from Mike Gibson, an Altiris Consultant, at the UK Altiris Forum meeting last year. The KB article however suffers from a lack in background information which makes it very difficult to troubleshoot in the event that your image compression doesn't work. So, consider that follows as KB22971 on steriods... and my hope is that this extra information will provide you a better starting point that I had. ;-)

The procedure for compressing the ISO image in broad terms is as follows,

  1. Install the Windows Embedded development Tools. This will give us the capability of using SDI technology (System Deployment Image) to convert our WinPE ISO image to the SDI format. This format is a portable XP Embedded file format, and it natively supports NTFS compression. It is this compression feature which we will make use of to bring our WinPE download size down.
  2. Convert the ISO image to an SDI file using the script attached to this article called called MakeSDI.bat. This is a modified version of the one downloadable directly from the Altiris KB.

    Substitute the existing WinPE boot option ISO image with the SDI file on the PXE server, adjusting the boot files accordingly.

  3. Give the PXE server a kick to resync

Sounds easy huh? Hmm... Lets give it a go...

Install the Windows XP SP1 Embedded Tools from Microsoft

  1. Download the web installer here.
  2. Run the Web Install program (XPEDDI.exe) and deselect all the products in theGUI with the exception of the topmost item, the Windows XP Embedded SP1 tools, and click 'Download Now'.

    Click to view.

  3. Once the tools are downloaded, click 'OK' to exit (you may receive a warning that disk 2 of setup cannot be found. I clicked 'OK' here, and everything seemed to work fine!)
  4. On the Windows Embedded setup screen, select Tools Setup to start installing the XP Embedded Studio tools. This suite of tools include the SDI utilities needed to create our compressed WinPE virtual disk image.

    Click to view.

  5. Click through the InstallShield wizard, leaving the defaults as is. The product key you'll find located in the text file C:\Program Files\Windows Embedded\Installer\DISK1\productkey.txt.

Create your WinPE source folder

Copy the contents of your WinPE ISO image to c:\WinPESrc. To remind yourself where the ISO is, open up the PXE Configuration utility and take a look at the WinPE boot options properties. The location of the ISO image is declared in the 'Final Location on PXE Server' text box, and should look similar to..\PXE\Images\MenuOption131.

The WinPE files can be grabbed from this ISO image in several ways,

  • Burn the ISO image to a CD, and then copy the contents to the folder
  • Use a Virtual CD-ROM application like Deamon Tools or Microsoft's XPVirtual CDROM Control Panel Applet to mount the ISO image.
  • Use a vitualisation product like VMWare Player or Workstation to mount the ISO image as a virtual CDROM Drive (yes, its overkill but if you already have VMWare installed and use if for development then this might actually be the fastest way!)
  • Use a disk imaging suite which supports ISO images like WinImage to explore and copy the contents off the ISO image.

Download and Run MakeSDI.bat

Download MakeSDI.bat from this article. Don't use the Altiris KB article download as it has a bug in the defrag commands and mine allows for a slightly bigger SDI file of 102MB rather than 94MB (I found the 94MB default to be a touch too small for my WinPE image).

The purpose of the MakeSDI batch file is to copy our WinPE source files onto a virtual disk represented by our SDI file. The syntax of MakeSDI.bat is as follows,


On my system, the X:\ is unused so I'm going to run this as

MakeSDI.bat C:\WinPESrc C:\WinPE.SDI X:

This script is does not (sadly) completely automate the process of creating your SDI file. There are three stages,

  1. Create the target SDI file, WinPE.SDI

    When the script runs, it will first use the SDI tools to create your SDI image fileC:\WinPE.SDI. This process creates a virtual disk, and sets its size to 103MB.

  2. Load the SDI Image as a virtual disk

    After the SDI file is created, the script pauses. In order to copy files to the SDI virtual disk image, we have to mount the image using the SDI Loader application. This is a manual process, and after pressing any key, the application loads. Click 'Add Disk' to browse to C:\WinPE.SDI. Once selected, click 'Done' to finish.

    Click to view.

  3. Clean, partition and mount the SDI Image

    After loading the SDI image as a virtual disk, we need to execute the following commands in DiskPart when it loads,

    1. list disk

      In order to point DiskPart to the correct disk for our disk operations, we must select the correct disk to operate on. This command reveals the currently attached disks. Our disk is the one listed as being 102MB, and should have the highest index (as it was the most recent disk to be attached to the system).

    2. select disk #

      Where # is the disk index discovered in the previous step. In most cases, the SDI disk will be disk 1, with disk 0 being your actual system harddisk.

    3. clean

      After selecting our SDI disk, we should ensure its completely blank. The clean command ensures the selected disk's partition table is wiped and ready for our next operation.

    4. create partition primary

      This command is quite remarkable in its clarity - this will create a primary partition on the disk. By default it will occupy the entire virtual space (minus a small overhead for the MBR, hence why I create the disk image 1MB more than the partition I want to write to it).

    5. assign letter=X

      This command assigns our newly made partition the drive letter X. At this point you should be able to view it in My Computer as an unformatted RAW filesystem.

  4. Format and File Copy

    Once you've completed the DiskPart, the X:\ drive is formatted with the NTFS filesystem (compression enabled) and the WinPE files are copied across. Viewing the X:\ drive in explorer should show this drive letter now as blue -reflecting the fact its been formatted as a compressed NTFS drive.

  5. Detach Virtual Disk

    After the files are copied across, the Storage Device Image Loader will be called again, this time to allow you to detach the virtual disk. Select your SDI file in the window, and click 'Remove Disk'.

    Notice this file is 102MB - nearly 50MB smaller than the original ISO image.

Replacing the WinPE.iso PXE Image with WinPE.SDI

Now that your virtual disk has been detached, your SDI file is safe to copy over to the PXE server to be used in your WinPE boot option. This process is actually rather tricky as syncing the PXE server with your new image file isn't directly supported by the PXE Configuration Utility interface. This means some manipulation behind the scenes is required.

In order for the following manual changes to make sense, it's wise to spend another minute or two re-iterating what happens when images are built and edited.

  • First, the PXE Server stores the configuration for each PXE boot menu in aMaster folder called ..\PXE\MasterImages\MenuOption###, where ### is a MenuOption number.

  • When images are edited in the PXE Configurator, an equivalent folder with the.tmp extension is created as a temporary working area for the new master.

  • When you've finished your edits and the option is saved in the interface, the temporary MenuOption folder replaces the live version. That is to say, theMenuOption### folder in MasterImages is deleted, and theMenuOption###.tmp folder is renamed to MenuOption###. Once this is complete, this folder is synced down to the PXE Server's live distribution folder under ..\PXE\Images.

With the above in mind, the steps load up our new PXE MenuOption with our SDI file are as follows,

  1. Delete the WinPE ISO Image from the MasterImage\MenuOption### folder

    As we'll not be booting off the WinPE.iso anymore, lets remove it from the Master folder. This will prevent the PXE server sync process being delayed by the copying of a now unused 150MB ISO image each time the Image folder gets synced with the MasterImage folder.

    On my server, the WinPE ISO image was stored under..\PXE\MasterImage\MenuOption131 (as revealed by looking at the properties of the PXE Boot option in the PXE Configuration Utility). So, the ISO I need to delete is in here, within the x86PC subfolder. Double check your particular MenuOption index, and delete the corresponding WinPE.ISO in the MasterImage folder now.

  2. Copy WinPE.SDI to the MasterImage\MenuOption folder

    In the folder you've just deleted the ISO image from, copy over into it the WinPE.SDI file. This is the file we are going to be downloading by TFTP instead of that previous bulky occupant, the ISO image.

  3. Modify Winnt.sif

    Winnt.sif currently expects to boot the WinPE ISO image. We need to modify this now so that it will accept the SDI image instead.

    The default Winnt.sif will look like (remember, in what follows ### is yourMenuOption number),

    BootDevice = "ramdisk(0)"
    BootPath = "\i386\system32\"
    OsLoadOptions = "/noguiboot /fastdetect /minint /rdexportascd /rdpath=MenuOption###\X86PC\winpe.iso /PXE_SERVER:**PXE_NAME** /PXE_IP:**PXE_IP** /PXE_PATH:MenuOption###\X86PC"

    and to make this load the SDI file we need to ammend the OsLoadOptions line as follows,

    OsLoadOptions = "/noguiboot /fastdetect /minint /rdimageoffset=36352 /rdpath=MenuOption###\X86PC\winpe.sdi /PXE_SERVER:**PXE_NAME** /PXE_IP:**PXE_IP** /PXE_PATH:MenuOption###\X86PC"

  4. Resync the PXE Server

    This is where it gets tricky, as the syncing the master folder requires us to do a little fudging.

    1. Open up the PXE Configuration Utility

    2. Select the WinPE option, and click 'Edit'.

    3. In the Edit Shared Menu Option window, select the Image Creation Method of User Supplied, and click 'Manual Boot Image'

    4. In the PXE Boot Files box that pops up, browse to any small folder on your C:\ Drive which has some .exe files (I typically choose my DOS files folder) and click OK. This step gears puts the PXE configurator into the stage where it creates the .tmp Master folder. Don't worry about the fact you've just put some random small files in here -the in the next step we will delete them!

    5. Delete the ..\PXE\MasterImages\MenuOption###.tmp folder which was created by the last step. We'll be fooling the PXE Configuration Utility into using our own .tmp folder in the next step.

    6. Rename the ..\PXE\MasterImages\MenuOption### folder to..\PXE\MasterImages\MenuOption###.tmp folder. Remember, the .tmpfolder is a staging area for the PXE Configurator, and this now contains our SDI WinPE build

    7. Close the Edit Shared Menu Option window by clicking 'OK'. Our .tmpmaster folder is now moved to the last staging point in the PXE Server as a .wrk folder

    8. In the PXE Configuration Utility, click 'OK' and when prompted save your work. This process moves the .wrkfolder to the master folder, and resyncs with the files in the ..\PXE\Images\MenuOption### folder

And that's it - your PXE server should be loaded up with a nice new trip WinPE Image. Try downloading now, and you should see a further drop in the WinPE TFTP download time, of about one third.

No comments: