Difference between revisions of "Windows PE"

From ThinkWiki
Jump to: navigation, search
m (add a link to p7zip)
(added syslinux boot option)
Line 1: Line 1:
Some utilities/drivers provided by IBM/Lenovo come only in the form of Windows executables (for example, [[Intel_Active_Management_Technology_(AMT)|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 [http://www.microsoft.com/downloads/en/results.aspx?pocId=&freetext=Automated%20Installation%20Kit&DisplayLang=en 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.
+
Some utilities/drivers provided by IBM/Lenovo come only in the form of Windows executables (for example, [[Intel_Active_Management_Technology_(AMT)|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 [http://www.microsoft.com/downloads/en/results.aspx?pocId=&freetext=Automated%20Installation%20Kit&DisplayLang=en 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). The latest version is [http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=696dd665-9f76-4177-a811-39c26d3b3b34 The Windows® Automated Installation Kit (AIK) for Windows® 7]. 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==
 
 
 
* '''7z''' from [http://sourceforge.net/projects/p7zip p7zip]
 
* '''genisoimage''' (or '''mkisofs''')
 
* '''qemu''' (or '''qemu-kvm''') virtual machine
 
 
 
and of course the ''Automated Installation Kit'' kit itself. The latest version is [http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=696dd665-9f76-4177-a811-39c26d3b3b34 The Windows® Automated Installation Kit (AIK) for Windows® 7]
 
  
 
==How to build a bootable WinPE *.iso image==
 
==How to build a bootable WinPE *.iso image==
 
+
* From the AIK installation file <tt>KB3AIK_EN.iso</tt>, provided in the form of a UDF disk image, use <tt>7z</tt> (from [http://sourceforge.net/projects/p7zip p7zip]) to extract the files <tt>wAIKX86.msi</tt> and <tt>WinPE.cab</tt>
* From the AIK installation file <tt>KB3AIK_EN.iso</tt>, provided in the form of a UDF disk image, use <tt>7z</tt> to extract the files <tt>wAIKX86.msi</tt> and <tt>WinPE.cab</tt>
+
* use <tt>7z</tt> or <tt>cabextract</tt> to unpack these files into <tt>/tmp/wAIKX86.msi/</tt> and <tt>/tmp/WinPE.cab/</tt> respectively
* use <tt>7z</tt> again to unpack these files into <tt>/tmp/wAIKX86.msi/</tt> and <tt>/tmp/WinPE.cab/</tt> respectively
 
 
* create a bootable WinPE *.iso image <tt>/tmp/winpe3_x86.iso</tt>
 
* create a bootable WinPE *.iso image <tt>/tmp/winpe3_x86.iso</tt>
 
  cd /tmp
 
  cd /tmp
 
  mkdir -p winpe3_x86/boot
 
  mkdir -p winpe3_x86/boot
 
  mkdir -p winpe3_x86/sources
 
  mkdir -p winpe3_x86/sources
 +
cp wAIKX86.msi/F_WINPE_X86_etfsboot.com winpe3_x86/etfsboot.com
 
  cp wAIKX86.msi/F1_BOOTMGR winpe3_x86/bootmgr
 
  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_bcd winpe3_x86/boot/bcd
 
  cp wAIKX86.msi/F_WINPE_X86_boot.sdi winpe3_x86/boot/boot.sdi
 
  cp wAIKX86.msi/F_WINPE_X86_boot.sdi winpe3_x86/boot/boot.sdi
 
  cp WinPE.cab/F1_WINPE.WIM winpe3_x86/sources/boot.wim
 
  cp WinPE.cab/F1_WINPE.WIM winpe3_x86/sources/boot.wim
cp wAIKX86.msi/F_WINPE_X86_etfsboot.com winpe3_x86/etfsboot.com
 
 
  genisoimage -sysid "" -A "" -V "Microsoft Windows PE (x86)" -d -N -b etfsboot.com -no-emul-boot \
 
  genisoimage -sysid "" -A "" -V "Microsoft Windows PE (x86)" -d -N -b etfsboot.com -no-emul-boot \
 
   -c boot.cat -hide etfsboot.com -hide boot.cat -o winpe3_x86.iso winpe3_x86
 
   -c boot.cat -hide etfsboot.com -hide boot.cat -o winpe3_x86.iso winpe3_x86
Line 27: Line 18:
  
 
==How to build a bootable WinPE USB-flash image==
 
==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.
+
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 (this seems to be a limitation of the Windows bootloader). Some BIOSes only support booting from USB-FDDs.
 +
 
 +
Since we already have a bootable WinPE *.iso image, we can use it to build a bootable WinPE USB-flash image in a virtual machine like '''qemu'''. Or, if for some ethical or religious reasons you do not want to run any Windows code even in a virtual machine -- you can build a bootable WinPE USB-flash image using '''syslinux'''.
  
 +
===Building WinPE USB-flash image in a virtual machine===
 
* prepare a blank
 
* prepare a blank
 
  dd if=/dev/zero of=winpe3_x86.img count=250000
 
  dd if=/dev/zero of=winpe3_x86.img count=250000
Line 48: Line 42:
 
  xcopy /s d:\* c:\
 
  xcopy /s d:\* c:\
 
  wpeutil shutdown
 
  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.
+
* when 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
 
  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.
 
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.
 +
 +
===Building WinPE USB-flash image with syslinux===
 +
 +
* prepare a blank
 +
dd if=/dev/zero of=winpe3_x86.img count=250000
 +
* create a bootable partition
 +
/sbin/parted winpe3_x86.img
 +
(parted) mklabel msdos
 +
(parted) unit s
 +
(parted) print free
 +
 +
Model:  (file)
 +
Disk /tmp/winpe3_x86.img: 250000s
 +
Sector size (logical/physical): 512B/512B
 +
Partition Table: msdos
 +
 +
Number  Start  End      Size    Type  File system  Flags
 +
        32s    249999s  249968s        Free Space
 +
 +
create a partition which takes all the available free space, ignore the warnings about the partition being non-aligned
 +
 +
(parted) mkpart primary fat32
 +
(parted) set 1 boot on
 +
(parted) print
 +
 +
Model:  (file)
 +
Disk /tmp/winpe3_x86.img: 250000s
 +
Sector size (logical/physical): 512B/512B
 +
Partition Table: msdos
 +
 +
Number  Start  End      Size    Type    File system  Flags
 +
  1      32s    249999s  249968s  primary              boot, lba
 +
* format and mount the partition
 +
# losetup -o $((32*512)) --sizelimit $((249968*512)) /dev/loop0 winpe3_x86.img
 +
# mkfs.vfat -F32 /dev/loop0
 +
# mount /dev/loop0 /media/sdb1
 +
* copy the files
 +
mkdir -p /media/sdb1/boot
 +
mkdir -p /media/sdb1/sources
 +
cp /tmp/wAIKX86.msi/F1_BOOTMGR /media/sdb1/bootmgr
 +
cp /tmp/wAIKX86.msi/F_WINPE_X86_bcd /media/sdb1/boot/bcd
 +
cp /tmp/wAIKX86.msi/F_WINPE_X86_boot.sdi /media/sdb1/boot/boot.sdi
 +
cp /tmp/WinPE.cab/F1_WINPE.WIM /media/sdb1/sources/boot.wim
 +
cp /usr/lib/syslinux/chain.c32 /media/sdb1/chain.c32
 +
* create the config file for /media/sdb1/syslinux.cfg
 +
DEFAULT WinPE
 +
LABEL WinPE
 +
        COM32 /chain.c32
 +
        APPEND boot ntldr=/BOOTMGR
 +
* install syslinux
 +
syslinux /dev/loop0
 +
umount -d /media/sdb1
 +
 +
* now you can copy this WinPE image on a flash media.
 +
dd if=winpe3_x86.img of=/dev/sdb
 +
 +
and use it for test/diagnostic tasks such as firmware upgrades.

Revision as of 20:43, 3 April 2010

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). The latest version is The Windows® Automated Installation Kit (AIK) for Windows® 7. 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.

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, use 7z (from p7zip) to extract the files wAIKX86.msi and WinPE.cab
  • use 7z or cabextract to unpack these files into /tmp/wAIKX86.msi/ and /tmp/WinPE.cab/ 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/F_WINPE_X86_etfsboot.com winpe3_x86/etfsboot.com
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 WinPE.cab/F1_WINPE.WIM winpe3_x86/sources/boot.wim
genisoimage -sysid "" -A "" -V "Microsoft Windows PE (x86)" -d -N -b etfsboot.com -no-emul-boot \
 -c boot.cat -hide etfsboot.com -hide boot.cat -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 (this seems to be a limitation of the Windows bootloader). Some BIOSes only support booting from USB-FDDs.

Since we already have a bootable WinPE *.iso image, we can use it to build a bootable WinPE USB-flash image in a virtual machine like qemu. Or, if for some ethical or religious reasons you do not want to run any Windows code even in a virtual machine -- you can build a bootable WinPE USB-flash image using syslinux.

Building WinPE USB-flash image in a virtual machine

  • 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.exe
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
  • when 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.

Building WinPE USB-flash image with syslinux

  • prepare a blank
dd if=/dev/zero of=winpe3_x86.img count=250000
  • create a bootable partition
/sbin/parted winpe3_x86.img
(parted) mklabel msdos
(parted) unit s
(parted) print free
Model:  (file)
Disk /tmp/winpe3_x86.img: 250000s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End      Size     Type  File system  Flags
        32s    249999s  249968s        Free Space

create a partition which takes all the available free space, ignore the warnings about the partition being non-aligned

(parted) mkpart primary fat32
(parted) set 1 boot on
(parted) print
Model:  (file)
Disk /tmp/winpe3_x86.img: 250000s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End      Size     Type     File system  Flags
 1      32s    249999s  249968s  primary               boot, lba
  • format and mount the partition
# losetup -o $((32*512)) --sizelimit $((249968*512)) /dev/loop0 winpe3_x86.img
# mkfs.vfat -F32 /dev/loop0
# mount /dev/loop0 /media/sdb1
  • copy the files
mkdir -p /media/sdb1/boot
mkdir -p /media/sdb1/sources
cp /tmp/wAIKX86.msi/F1_BOOTMGR /media/sdb1/bootmgr
cp /tmp/wAIKX86.msi/F_WINPE_X86_bcd /media/sdb1/boot/bcd
cp /tmp/wAIKX86.msi/F_WINPE_X86_boot.sdi /media/sdb1/boot/boot.sdi
cp /tmp/WinPE.cab/F1_WINPE.WIM /media/sdb1/sources/boot.wim
cp /usr/lib/syslinux/chain.c32 /media/sdb1/chain.c32
  • create the config file for /media/sdb1/syslinux.cfg
DEFAULT WinPE
LABEL WinPE
        COM32 /chain.c32
        APPEND boot ntldr=/BOOTMGR
  • install syslinux
syslinux /dev/loop0
umount -d /media/sdb1
  • now you can copy this WinPE image on a flash media.
dd if=winpe3_x86.img of=/dev/sdb

and use it for test/diagnostic tasks such as firmware upgrades.