Windows Preinstallation Environment is a lightweight system, less than 300Mo for the disk image. When we boot a WinPE, we only have a cmd console and we can do all necessary think to install a computer.
Get it from CDROM
Explode the windows cdrom/iso (server or desktop), and get some boot files, you can find it in the sources and bootdirectory.
The boot.wim file is the only file we need to boot a valid winpe system, and /boot/boot.sdi and /bootmgr
How to create boot image
We can create a usb boot device, but i want a netboot winpe system. So we need to create a boot disk image loadable by gPXE.
The Steps are:
Get a Usb drive (512Mo not more than 512), or create a partition with a size of 512M, add the boot.wim file in this paritition. add the boot sector, and dump this disk to an image disk.
modus operandi
On Linux:
mkfs.ntfs -f -L WinPE /dev/sdb1mount /dev/sdb1 /mntcp /data/Windows/boot.wim /data/Windows/bootmgr /data/Windows/boot.sdi /mntmkdir /mnt/BCDumount /mntOn Windows, if we consider b: as the drive of the usb disk:
bcdedit /store b:\boot\BCD /set {bootmgr} timeout 5bcdedit /store b:\boot\BCD /create {ramdiskoptions}bcdedit /store b:\boot\BCD /set {ramdiskoptions} ramdisksdidevice bootbcdedit /store b:\boot\BCD /set {ramdiskoptions} ramdisksdipath \boot\boot.sdifor /f "tokens=3" %a in ('bcdedit /store b:\boot\BCD /create /d "Boot Windows PE" /application OSLOADER') do set GUID=%abcdedit /store b:\boot\BCD /set %GUID% device ramdisk=[boot]\boot.wim,{ramdiskoptions}bcdedit /store b:\boot\BCD /set %GUID% osdevice ramdisk=[boot]\boot.wim,{ramdiskoptions}bcdedit /store b:\boot\BCD /set %GUID% systemroot \windowsbcdedit /store b:\boot\BCD /set %GUID% detecthal yesbcdedit /store b:\boot\BCD /set %GUID% winpe yesbcdedit /store c:\boot\BCD /ems {default} onbcdedit /store c:\boot\BCD /bootems {bootmgr} onbcdedit /store b:\boot\BCD /displayorder %GUID% /addlastNow we have a usb drive for booting WinPE system, we can make a winpe.img now.
On linux again:
dd if=/dev/sdb1 of=/data/Windows/winpe.img bs=1024kgzip winpe.imgNow we have the winpe image we describe in basis gPXE setup, but gzip the file memdisk can gunzip it on the fly.
How to modify
Now, for customing this system, we can modify or change the boot.wim file.
For doing this the steps are:
Modus operandi
This part can be done on linux, we mount a loop device at osfset 65536.
losetup -o 65536 /dev/loop0 /data/Windows/winpe.imgmount -o loop /dev/loop0 /mntcp /data/windows/NewWinPe.wim /mnt/boot/wimumount /mntlosetup -d /dev/loop/0How to modify the boot.wim file
For doing this we must have WAIK2 system. We talk about that later.