Windows PE

From ThinkWiki
Revision as of 06:04, 22 March 2010 by Newhren (Talk | contribs)
Jump to: navigation, search

Some utilities/drivers provided by IBM/Lenovo come only in the form of Windows executables (for example, Intel AMT firmware updates). And for people who don't use Windows OS on their computers it becomes impossible to use/apply them. Luckily, Microsoft provides Automated Installation Kit (aka AIK) for free to everyone with very few resctictions on usage (basically, they only prohibit using it as a substitute of a "real" OS, and allow to use it for any diagnostic and reapair tasks). Users of Windows OS can use this AIK to create bootable CD-ROMs and bootable USB-flash drives with Windows PE (or WinPE for short), which is essentially a stripped-down version of Windows. In this article we will explain how to create bootable CD-ROMs and USB-flash drives with WinPE using only FOSS software.

Tools we will need

  • cabextract
  • genisoimage (or mkisofs)
  • qemu (or qemu-kvm) virtual machine

and of course the Automated Installation Kit kit itself. The latest version is The Windows® Automated Installation Kit (AIK) for Windows® 7

How to build a bootable WinPE *.iso image

  • From the AIK installation file KB3AIK_EN.iso, provided in the form of a UDF disk image, extract the files wAIKX86.msi and
  • using cabextract, unpack these files into /tmp/wAIKX86.msi/ and /tmp/ respectively
  • create a bootable WinPE *.iso image /tmp/winpe3_x86.iso
cd /tmp
mkdir -p winpe3_x86/boot
mkdir -p winpe3_x86/sources
cp wAIKX86.msi/F1_BOOTMGR winpe3_x86/bootmgr
cp wAIKX86.msi/F_WINPE_X86_bcd winpe3_x86/boot/bcd
cp wAIKX86.msi/F_WINPE_X86_boot.sdi winpe3_x86/boot/boot.sdi
cp winpe3_x86/sources/boot.wim
cp wAIKX86.msi/ winpe3_x86/
genisoimage -sysid "" -A "" -V "Microsoft Windows PE (x86)" -d -N -b -no-emul-boot \
 -c -hide -hide -o winpe3_x86.iso winpe3_x86

the file you will get will be about 120M in size. Then you can burn this *.iso and boot it on any x86-machine which supports booting from CD-ROMs (which is pretty much any PC today)

How to build a bootable WinPE USB-flash image

a more convenient option would be to create a bootable USB-flash drive. Unfortunately, you will only be able to use it on PCs which support booting from USB-HDDs. Some BIOSes only support booting from USB-FDDs.

  • prepare a blank
dd if=/dev/zero of=winpe3_x86.img count=250000
  • boot winpe3_x86.iso (which you've created before) in a virtual machine
qemu -cdrom winpe3_x86.iso -boot d -m 640 -hda winpe3_x86.img
  • now, in the shell provided by WinPE in the virtual machine
diskpart> list disk
diskpart> select disk 0
diskpart> clean
diskpart> create partition primary
diskpart> list partition
diskpart> select partition 1
diskpart> format fs=fat32 quick
diskpart> active
diskpart> assign
diskpart> list volume
diskpart> exit
xcopy /s d:\* c:\
wpeutil shutdown
  • then the virtual machine shuts down, you can copy WinPE image on a flash media. It will fit on any media > 125M in size.
dd if=winpe3_x86.img of=/dev/sdb

and use it for test/diagnostic tasks such as firmware upgrades. If you want, you can create an additional partition for you firmware/diagnostic tools, just don't mess with the partition created by Windows -- you may reder it unbootable.