Difference between revisions of "Windows PE"

From ThinkWiki
Jump to: navigation, search
(add USB-FDD boot option)
(Current release of wimlib-1.9.0 (released January 31, 2016))
 
(22 intermediate revisions by 2 users not shown)
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). 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.
+
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 install this AIK and 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 free software. Moreover, free software allows to create bootable USB-FDD with WinPE -- the feature not available to users of Microsoft tools :).
  
 
==How to build a bootable WinPE *.iso image==
 
==How to build a bootable WinPE *.iso image==
 +
===Using wimlib===
 +
* Download, build and install wimlib https://wimlib.net/  Current release: wimlib-1.9.0 (released January 31, 2016)
 +
** On Debian-based systems:
 +
    sudo apt-get install debhelper autotools-dev pkg-config libfuse-dev libxml2-dev libssl-dev ntfs-3g-dev attr-dev attr
 +
    wget https://wimlib.net/downloads/wimlib-1.9.0.tar.gz
 +
    tar -xzf wimlib-1.9.0.tar.gz
 +
    cd wimlib-1.9.0
 +
    dpkg-buildpackage -uc -us -rfakeroot
 +
    sudo dpkg -i ../wimlib_1.9.0-1_amd64.deb ../wimtools_1.9.0-1_amd64.deb
 +
* Mount the AIK image
 +
    mkdir waik
 +
    sudo mount -o loop,ro KB3AIK_EN.iso waik
 +
* Create the WinPE image (with drivers extracted by wine)
 +
    mkwinpeimg --iso --waik-dir=$PWD/waik winpe3_x86.iso --overlay=$HOME/.wine/drive_c/DRIVERS
 +
* Unmount the AIK image
 +
    sudo umount waik
 +
 +
===Using standard tools===
 
* 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> (from [http://sourceforge.net/projects/p7zip p7zip]) 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> or <tt>cabextract</tt> to unpack these files into <tt>/tmp/wAIKX86.msi/</tt> and <tt>/tmp/WinPE.cab/</tt> respectively
Line 18: Line 36:
  
 
==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, Windows loader does not support booting from USB-FDD, while for some BIOSes this is the only type of bootable USB devices. If this is your case, you will have to create a virtual CDROM with <tt>memdisk</tt> from '''syslinux''' and boot the *.iso image you've created in the previous step. The drawback is that you will have to sacrifice 120Mb or so of RAM for the virtual CDROM, but the advantage is that this USB-image will be bootable on any PC.
+
a more convenient option would be to create a bootable USB-flash drive. Unfortunately, Windows loader <tt>bootmgr</tt> does not seem to support booting from USB-FDDs, while for some BIOSes this is the only type of bootable USB-flash devices.
  
===Building WinPE USB-HDD image in a virtual machine===
+
===Building WinPE USB-HDD image natively in a virtual machine===
Since we already have a bootable WinPE *.iso image, we can use it to build a bootable WinPE USB-HDD image in a virtual machine like '''qemu'''.
+
Since we already have a bootable WinPE *.iso image, we can use native Windows tools to build a bootable WinPE USB-HDD image in a virtual machine like '''qemu'''.
 
* prepare a blank
 
* prepare a blank
  dd if=/dev/zero of=winpe3_x86.img count=250000
+
  dd if=/dev/zero of=winpe3_x86hdd.img count=250000
 
* boot <tt>winpe3_x86.iso</tt> (which you've created before) in a virtual machine
 
* boot <tt>winpe3_x86.iso</tt> (which you've created before) in a virtual machine
  qemu -cdrom winpe3_x86.iso -boot d -m 640 -hda winpe3_x86.img
+
  qemu -enable-kvm -machine accel=kvm -cdrom winpe3_x86.iso -boot d -m 300 -hda winpe3_x86hdd.img
 
* now, in the shell provided by WinPE in the virtual machine
 
* now, in the shell provided by WinPE in the virtual machine
 
  diskpart.exe
 
  diskpart.exe
Line 41: Line 59:
 
  xcopy /s d:\* c:\
 
  xcopy /s d:\* c:\
 
  wpeutil shutdown
 
  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.
+
* when the virtual machine shuts down, the bootable WinPE image is ready. If you have write permissions for some flash media device (e.g. <tt>/dev/sdb</tt>), you can copy it with
  dd if=winpe3_x86.img of=/dev/sdb
+
  # dd if=winpe3_x86hdd.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-HDD image with syslinux===
+
===Building WinPE USB-HDD image with mtools and syslinux===
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-HDD image using '''syslinux'''.
+
if for some ethical or religious reasons you do not want to run any Windows code even in a virtual machine, or you don't have a virtual machine at all -- you can build a bootable WinPE USB-HDD image using '''syslinux''' and '''mtools'''.
* prepare a blank
+
* create and format the partition image
  dd if=/dev/zero of=winpe3_x86.img count=250000
+
dd if=/dev/zero of=winpe3_x86part.img count='''234000'''
* create a bootable partition
+
/sbin/mkfs.vfat -F32 winpe3_x86part.img
  parted winpe3_x86.img
+
Note: it looks that '''234000''' is the minimal possible size, but you can choose a bigger number.
 +
* copy the files (you may have to put "mtools_skip_check=1" into <tt>~/.mtoolsrc</tt> if your partition is not aligned like mine)
 +
mmd -i winpe3_x86part.img boot
 +
mmd -i winpe3_x86part.img sources
 +
mcopy -i winpe3_x86part.img /tmp/wAIKX86.msi/F1_BOOTMGR ::/bootmgr
 +
mcopy -i winpe3_x86part.img /tmp/wAIKX86.msi/F_WINPE_X86_bcd ::/boot/bcd
 +
mcopy -i winpe3_x86part.img /tmp/wAIKX86.msi/F_WINPE_X86_boot.sdi ::/boot/boot.sdi
 +
mcopy -i winpe3_x86part.img /tmp/WinPE.cab/F1_WINPE.WIM ::/sources/boot.wim
 +
mcopy -i winpe3_x86part.img /usr/lib/syslinux/chain.c32 ::/chain.c32
 +
* create the config file <tt>/tmp/syslinux.cfg</tt> and copy it
 +
DEFAULT WinPE
 +
LABEL WinPE
 +
        COM32 /chain.c32
 +
        APPEND boot ntldr=/bootmgr
 +
 
 +
mcopy -i winpe3_x86part.img /tmp/syslinux.cfg ::/syslinux.cfg
 +
* install syslinux
 +
syslinux winpe3_x86part.img
 +
* create USB-HDD image of the size at least '''32''' sectors bigger than the size of the partition we've just created
 +
  dd if=/dev/zero of=winpe3_x86hdd.img count='''234032'''
 +
* create a bootable partition entry
 +
  /sbin/parted winpe3_x86hdd.img
 
  (parted) mklabel msdos
 
  (parted) mklabel msdos
 
  (parted) unit s
 
  (parted) unit s
Line 57: Line 96:
 
  (parted) set 1 boot on
 
  (parted) set 1 boot on
 
  (parted) print
 
  (parted) print
in my case the output looks like this. Note the numbers corresponding to "Start" and "Size" of your partition, we will use them in the next command
+
(parted) quit
Model:  (file)
+
* copy the partition image into the disk image
  Disk /tmp/winpe3_x86.img: 250000s
+
dd if=winpe3_x86part.img of=winpe3_x86hdd.img seek='''32'''
Sector size (logical/physical): 512B/512B
+
where '''32''' is the start sector of your partition
Partition Table: msdos
+
* now the image is ready. If you have write permissions for some flash media device (e.g. <tt>/dev/sdb</tt>), you can copy it with
+
  # dd if=winpe3_x86hdd.img of=/dev/sdb
Number  Start  End      Size    Type    File system  Flags
+
and use it for test/diagnostic tasks such as firmware upgrades.
  1      32s    249999s  249968s  primary              boot, lba
+
 
* format and mount the partition
+
===Building WinPE USB-FDD image with mtools, syslinux and grub4dos===
losetup -o $((32*512)) --sizelimit $((249968*512)) /dev/loop0 winpe3_x86.img
+
Any BIOS that supports booting from some USB media at all supports booting from USB-FDD. As it was mentioned ealier, the problem with WinPE is that the bootloader <tt>bootmgr</tt> does not seem to like such devices. So, we will have to create a virtual HDD or a virtual CDROM (I prefer virtual HDD). For some mystical reason, <tt>memdisk</tt> (the dirver for virtual disks which comes with syslinux) does not work on Thinkpads if the disk image is on a USB media. Thus we will use a rival technology [http://sourceforge.net/projects/grub4dos/files/ grub4dos].
mkfs.vfat -F32 /dev/loop0
+
* create USB-FDD image
mount /dev/loop0 /media/sdb1
+
  dd if=/dev/zero of=winpe3_x86fdd.img count='''238200'''
* copy the files
+
  /sbin/mkfs.vfat -F32 winpe3_x86fdd.img
  mkdir -p /media/sdb1/boot
+
Note: it looks that '''238200''' is the minimal possible size, but you can choose a bigger number.
  mkdir -p /media/sdb1/sources
+
* download [http://sourceforge.net/projects/grub4dos/files/ grub4dos] and copy <tt>grub.exe</tt>
cp /tmp/wAIKX86.msi/F1_BOOTMGR /media/sdb1/bootmgr
+
  mcopy -i winpe3_x86fdd.img grub.exe ::/
cp /tmp/wAIKX86.msi/F_WINPE_X86_bcd /media/sdb1/boot/bcd
+
* copy the payload
  cp /tmp/wAIKX86.msi/F_WINPE_X86_boot.sdi /media/sdb1/boot/boot.sdi
+
  mcopy -i winpe3_x86fdd.img winpe3_x86part.img ::/
  cp /tmp/WinPE.cab/F1_WINPE.WIM /media/sdb1/sources/boot.wim
+
Note that this is the image of the partition, not of the whole HD. The reason why it works is grub.exe's [http://grub4dos.sourceforge.net/wiki/index.php/Grub4dos_tutorial#Auto_MBR_creation Auto MBR creation] feature, which tricks <tt>bootmgr</tt> into thinking that it boots from a real HD.
cp /usr/lib/syslinux/chain.c32 /media/sdb1/chain.c32
+
* create the config file <tt>/tmp/syslinux.cfg</tt> and copy it
* create the config file /media/sdb1/syslinux.cfg
 
 
  DEFAULT WinPE
 
  DEFAULT WinPE
 
  LABEL WinPE
 
  LABEL WinPE
         COM32 /chain.c32
+
         KERNEL /grub.exe
         APPEND boot ntldr=/bootmgr
+
         APPEND --config-file="map (rd) (fd0); map --hook; chainloader (fd0)+1; rootnoverify (fd0)"
* install syslinux
+
        INITRD /winpe3_x86part.img
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.
+
mcopy -i winpe3_x86fdd.img /tmp/syslinux.cfg ::/syslinux.cfg
 
+
'''Note''': for a virtual CDROM, your <tt>syslinux.cfg</tt> should look like
===Building WinPE USB-FDD image with syslinux===
 
* prepare a blank
 
dd if=/dev/zero of=winpe3_x86.img count=250000
 
* format and mount the image
 
losetup /dev/loop0 winpe3_x86.img
 
mkfs.vfat -F32 /dev/loop0
 
mount /dev/loop0 /media/sdb
 
* copy the files
 
cp /tmp/winpe3_x86.iso /media/sdb/
 
cp /usr/lib/syslinux/memdisk /media/sdb/
 
* create the config file /media/sdb/syslinux.cfg
 
 
  DEFAULT WinPE
 
  DEFAULT WinPE
 
  LABEL WinPE
 
  LABEL WinPE
         KERNEL /memdisk
+
         KERNEL /grub.exe
 +
        APPEND --config-file="map (rd) (hd32); map --hook; root (hd32); chainloader (hd32)"
 
         INITRD /winpe3_x86.iso
 
         INITRD /winpe3_x86.iso
         APPEND iso
+
'''Note''': if your computer is low on RAM (less than 350Mb) you may also try the following <tt>syslinux.cfg</tt> with direct mapping and make sure that the payload <tt>winpe3_x86part.img</tt> is in one contiguous disk area.
 +
DEFAULT WinPE
 +
LABEL WinPE
 +
        KERNEL /grub.exe
 +
         APPEND --config-file="map (hd0)/winpe3_x86part.img (fd0); map --hook; chainloader (fd0)+1; rootnoverify (fd0)"
 
* install syslinux
 
* install syslinux
  syslinux /dev/loop0
+
  syslinux winpe3_x86fdd.img
umount -d /media/sdb
+
* now the image is ready. If you have write permissions for some flash media device (e.g. <tt>/dev/sdb</tt>), you can copy it with
* now you can copy this WinPE image on a flash media.
+
  # dd if=winpe3_x86fdd.img of=/dev/sdb
  dd if=winpe3_x86.img of=/dev/sdb
 
 
 
 
and use it for test/diagnostic tasks such as firmware upgrades.
 
and use it for test/diagnostic tasks such as firmware upgrades.

Latest revision as of 16:04, 6 February 2016

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 install this AIK and 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 free software. Moreover, free software allows to create bootable USB-FDD with WinPE -- the feature not available to users of Microsoft tools :).

How to build a bootable WinPE *.iso image

Using wimlib

  • Download, build and install wimlib https://wimlib.net/ Current release: wimlib-1.9.0 (released January 31, 2016)
    • On Debian-based systems:
   sudo apt-get install debhelper autotools-dev pkg-config libfuse-dev libxml2-dev libssl-dev ntfs-3g-dev attr-dev attr
   wget https://wimlib.net/downloads/wimlib-1.9.0.tar.gz
   tar -xzf wimlib-1.9.0.tar.gz
   cd wimlib-1.9.0
   dpkg-buildpackage -uc -us -rfakeroot
   sudo dpkg -i ../wimlib_1.9.0-1_amd64.deb ../wimtools_1.9.0-1_amd64.deb
  • Mount the AIK image
   mkdir waik
   sudo mount -o loop,ro KB3AIK_EN.iso waik
  • Create the WinPE image (with drivers extracted by wine)
   mkwinpeimg --iso --waik-dir=$PWD/waik winpe3_x86.iso --overlay=$HOME/.wine/drive_c/DRIVERS
  • Unmount the AIK image
   sudo umount waik

Using standard tools

  • 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, Windows loader bootmgr does not seem to support booting from USB-FDDs, while for some BIOSes this is the only type of bootable USB-flash devices.

Building WinPE USB-HDD image natively in a virtual machine

Since we already have a bootable WinPE *.iso image, we can use native Windows tools to build a bootable WinPE USB-HDD image in a virtual machine like qemu.

  • prepare a blank
dd if=/dev/zero of=winpe3_x86hdd.img count=250000
  • boot winpe3_x86.iso (which you've created before) in a virtual machine
qemu -enable-kvm -machine accel=kvm -cdrom winpe3_x86.iso -boot d -m 300 -hda winpe3_x86hdd.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, the bootable WinPE image is ready. If you have write permissions for some flash media device (e.g. /dev/sdb), you can copy it with
# dd if=winpe3_x86hdd.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-HDD image with mtools and syslinux

if for some ethical or religious reasons you do not want to run any Windows code even in a virtual machine, or you don't have a virtual machine at all -- you can build a bootable WinPE USB-HDD image using syslinux and mtools.

  • create and format the partition image
dd if=/dev/zero of=winpe3_x86part.img count=234000
/sbin/mkfs.vfat -F32 winpe3_x86part.img

Note: it looks that 234000 is the minimal possible size, but you can choose a bigger number.

  • copy the files (you may have to put "mtools_skip_check=1" into ~/.mtoolsrc if your partition is not aligned like mine)
mmd -i winpe3_x86part.img boot
mmd -i winpe3_x86part.img sources
mcopy -i winpe3_x86part.img /tmp/wAIKX86.msi/F1_BOOTMGR ::/bootmgr
mcopy -i winpe3_x86part.img /tmp/wAIKX86.msi/F_WINPE_X86_bcd ::/boot/bcd
mcopy -i winpe3_x86part.img /tmp/wAIKX86.msi/F_WINPE_X86_boot.sdi ::/boot/boot.sdi
mcopy -i winpe3_x86part.img /tmp/WinPE.cab/F1_WINPE.WIM ::/sources/boot.wim
mcopy -i winpe3_x86part.img /usr/lib/syslinux/chain.c32 ::/chain.c32
  • create the config file /tmp/syslinux.cfg and copy it
DEFAULT WinPE
LABEL WinPE
        COM32 /chain.c32
        APPEND boot ntldr=/bootmgr
mcopy -i winpe3_x86part.img /tmp/syslinux.cfg ::/syslinux.cfg
  • install syslinux
syslinux winpe3_x86part.img
  • create USB-HDD image of the size at least 32 sectors bigger than the size of the partition we've just created
dd if=/dev/zero of=winpe3_x86hdd.img count=234032
  • create a bootable partition entry
/sbin/parted winpe3_x86hdd.img
(parted) mklabel msdos
(parted) unit s
(parted) print free
(parted) mkpart primary fat32
(parted) set 1 boot on
(parted) print
(parted) quit
  • copy the partition image into the disk image
dd if=winpe3_x86part.img of=winpe3_x86hdd.img seek=32

where 32 is the start sector of your partition

  • now the image is ready. If you have write permissions for some flash media device (e.g. /dev/sdb), you can copy it with
# dd if=winpe3_x86hdd.img of=/dev/sdb

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

Building WinPE USB-FDD image with mtools, syslinux and grub4dos

Any BIOS that supports booting from some USB media at all supports booting from USB-FDD. As it was mentioned ealier, the problem with WinPE is that the bootloader bootmgr does not seem to like such devices. So, we will have to create a virtual HDD or a virtual CDROM (I prefer virtual HDD). For some mystical reason, memdisk (the dirver for virtual disks which comes with syslinux) does not work on Thinkpads if the disk image is on a USB media. Thus we will use a rival technology grub4dos.

  • create USB-FDD image
dd if=/dev/zero of=winpe3_x86fdd.img count=238200
/sbin/mkfs.vfat -F32 winpe3_x86fdd.img

Note: it looks that 238200 is the minimal possible size, but you can choose a bigger number.

mcopy -i winpe3_x86fdd.img grub.exe ::/
  • copy the payload
mcopy -i winpe3_x86fdd.img winpe3_x86part.img ::/

Note that this is the image of the partition, not of the whole HD. The reason why it works is grub.exe's Auto MBR creation feature, which tricks bootmgr into thinking that it boots from a real HD.

  • create the config file /tmp/syslinux.cfg and copy it
DEFAULT WinPE
LABEL WinPE
        KERNEL /grub.exe
        APPEND --config-file="map (rd) (fd0); map --hook; chainloader (fd0)+1; rootnoverify (fd0)"
        INITRD /winpe3_x86part.img
mcopy -i winpe3_x86fdd.img /tmp/syslinux.cfg ::/syslinux.cfg

Note: for a virtual CDROM, your syslinux.cfg should look like

DEFAULT WinPE
LABEL WinPE
        KERNEL /grub.exe
        APPEND --config-file="map (rd) (hd32); map --hook; root (hd32); chainloader (hd32)"
        INITRD /winpe3_x86.iso

Note: if your computer is low on RAM (less than 350Mb) you may also try the following syslinux.cfg with direct mapping and make sure that the payload winpe3_x86part.img is in one contiguous disk area.

DEFAULT WinPE
LABEL WinPE
        KERNEL /grub.exe
        APPEND --config-file="map (hd0)/winpe3_x86part.img (fd0); map --hook; chainloader (fd0)+1; rootnoverify (fd0)"
  • install syslinux
syslinux winpe3_x86fdd.img
  • now the image is ready. If you have write permissions for some flash media device (e.g. /dev/sdb), you can copy it with
# dd if=winpe3_x86fdd.img of=/dev/sdb

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