Netboot/Windows 7

From Sidvind
Jump to: navigation, search
using pxelinux and tftp.

This guide shows how to netboot a Windows 7 installation using Windows PE and allow serving both x86 and x64 images at the same time. It assumes you already have pxelinux running.

The process is divided into four parts:

  • Creating the Windows PE image which is loaded by the bootloader.
  • Creating the bootloader image which will be a single iso usable by the memdisk kernel (from syslinux) instead of bloating the TFTP server with fixed filenames.
  • Setup samba share serving installation media.
  • Configure syslinux.

Instructions loosely based on [1].


  • Windows AIK
  • Windows 7 Repair CD (as ISO)
  • Windows 7 Installation media (as ISO)
  • Samba

Windows PE image[edit]

From an existing windows installation. Replace x86 with amd64 (x64, including intel) or ia64 (for intel Itanium only, if you have a core2 duo or similar use amd64)

  1. Install Windows AIK and run deployment console
  2. copype.cmd x86 C:\Path
  3. cd Path (If you don't want to autostart the setup or otherwise customize the environment you can skip to the last step.)
  4. mkdir mount
  5. imagex /mountrw winpe.wim 1 mount
  6. edit mount\Windows\System32\startnet.cmd (see below, remember to be admin or you cannot save file). Unlike optical media and usb, Windows PE will not attempt and unattended installation unless otherwise specified using the /unattended flag (e.g /unattend:z:\Autounattend.xml).
  7. imagex /unmount /commit mount
  8. Upload winpe.wim to where you want to create boot image.

If you need any special files included in the booted environment copy them before unmounting the image, but it might be easier to access files using samba later.

Code: startnet.cmd (view, download)

  1. wpeinit
  2. @net use z: \\SERVER\PATH
  3. @SET PATH=%PATH%;"z:\"
  4. @echo Installation media mounted on z:
  5. @setup

Bootloader image[edit]

  1. mkdir winpe_boot temp
  2. mount -o loop win7_repair.iso temp
  3. rsync -avP temp/* winpe_boot
  4. perl win7_repair.iso > winpe_boot/boot.bin
  5. cp bootstrap.bat bootstrap.diskpart winpe_boot
  6. cd winpe_boot
  7. mkisofs -udf -v -b boot.bin -no-emul-boot -o ../WinPE_bootstrap.iso .
  8. Create virtual machine which at 160MB disk (if your winpe.wim image is large you might need more) and boot using the iso you created.
  9. Enter command prompt and execute bootstrap script (available on disc, e.g. D:), watch output for any failures.
  10. Reboot to a linux live cd
  11. dd if=/dev/hda of=winpe.img
  12. scp winpe.img SERVER:DST (upload this to the tftp root)

Code: bootstrap.bat (view, download)

  1. @echo This will erase and overwrite disk 0 with WinPE bootloader.
  2. @echo Abort now if this isn't what you intend to do.
  3. @pause
  4. diskpart /s bootstrap.diskpart
  5. c:
  6. mkdir boot
  7. copy d:\bootmgr c:\
  8. copy d:\boot\boot.sdi c:\
  9. copy d:\winpe.wim c:\
  10. attrib +s +h +r c:\bootmgr
  11. bcdedit -createstore c:\boot\BCD
  12. bcdedit -import c:\boot\BCD
  13. bcdedit -create {bootmgr} /d "Boot Manager"
  14. for /f "tokens=3" %%a in ('bcdedit -create -application osloader /d "WinPE"') do set GUID=%%a
  15. bcdedit -create {ramdiskoptions} /d "Ramdisk Options"
  16. bcdedit -set {bootmgr} device partition=C:
  17. bcdedit -set {bootmgr} default %GUID%
  18. bcdedit -set {default} device ramdisk=[C:]\winpe.wim,{ramdiskoptions}
  19. bcdedit -set {default} osdevice ramdisk=[C:]\winpe.wim,{ramdiskoptions}
  20. bcdedit -set {default} path \windows\system32\boot\winload.exe
  21. bcdedit -set {default} systemroot \windows
  22. bcdedit -set {default} detecthal yes
  23. bcdedit -set {default} winpe yes
  24. bcdedit -set {ramdiskoptions} ramdisksdidevice partition=C:
  25. bcdedit -set {ramdiskoptions} ramdisksdipath \boot.sdi

Code: bootstrap.diskpart (view, download)

  1. select disk 0
  2. create partition primary
  3. select partition 1
  4. format fs=ntfs quick
  5. active
  6. assign letter=c


Setup a public readable samba share containing the real installation image, e.g. mounted as loopback. Replace names, interfaces and subnets as you see fit.

Code: smb.conf (view, download)

  1. [global]
  2.         workgroup = WORKGROUP
  3.         server string = SERVER
  4.         interfaces = eth1
  5.         bind interfaces only = Yes
  6.         map to guest = Bad User
  7.         hosts allow = 10.0.44., 127.
  9. [export]
  10.         path = /export
  11.         guest ok = Yes

Assuming you don't change the username (see docs) the anon user will be "nobody", so setup a empty password using:

smbpasswd -an nobody


LABEL Windows PE
     kernel memdisk
     initrd winpe.img

Might have to append "raw".