Netboot/Windows 7
Netboot |
---|
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].
Requirements[edit]
- 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)
- Install Windows AIK and run deployment console
- copype.cmd x86 C:\Path
- cd Path (If you don't want to autostart the setup or otherwise customize the environment you can skip to the last step.)
- mkdir mount
- imagex /mountrw winpe.wim 1 mount
- 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).
- imagex /unmount /commit mount
- 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.
- wpeinit
- @net use z: \\SERVER\PATH
- @SET PATH=%PATH%;"z:\"
- @echo Installation media mounted on z:
- @setup
Bootloader image[edit]
- mkdir winpe_boot temp
- mount -o loop win7_repair.iso temp
- rsync -avP temp/* winpe_boot
- perl geteltorito.pl win7_repair.iso > winpe_boot/boot.bin
- cp winpe.win bootstrap.bat bootstrap.diskpart winpe_boot
- cd winpe_boot
- mkisofs -udf -v -b boot.bin -no-emul-boot -o ../WinPE_bootstrap.iso .
- 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.
- Enter command prompt and execute bootstrap script (available on disc, e.g. D:), watch output for any failures.
- Reboot to a linux live cd
- dd if=/dev/hda of=winpe.img
- scp winpe.img SERVER:DST (upload this to the tftp root)
- @echo This will erase and overwrite disk 0 with WinPE bootloader.
- @echo Abort now if this isn't what you intend to do.
- @pause
- diskpart /s bootstrap.diskpart
- c:
- mkdir boot
- copy d:\bootmgr c:\
- copy d:\boot\boot.sdi c:\
- copy d:\winpe.wim c:\
- attrib +s +h +r c:\bootmgr
- bcdedit -createstore c:\boot\BCD
- bcdedit -import c:\boot\BCD
- bcdedit -create {bootmgr} /d "Boot Manager"
- for /f "tokens=3" %%a in ('bcdedit -create -application osloader /d "WinPE"') do set GUID=%%a
- bcdedit -create {ramdiskoptions} /d "Ramdisk Options"
- bcdedit -set {bootmgr} device partition=C:
- bcdedit -set {bootmgr} default %GUID%
- bcdedit -set {default} device ramdisk=[C:]\winpe.wim,{ramdiskoptions}
- bcdedit -set {default} osdevice ramdisk=[C:]\winpe.wim,{ramdiskoptions}
- bcdedit -set {default} path \windows\system32\boot\winload.exe
- bcdedit -set {default} systemroot \windows
- bcdedit -set {default} detecthal yes
- bcdedit -set {default} winpe yes
- bcdedit -set {ramdiskoptions} ramdisksdidevice partition=C:
- bcdedit -set {ramdiskoptions} ramdisksdipath \boot.sdi
- select disk 0
- create partition primary
- select partition 1
- format fs=ntfs quick
- active
- assign letter=c
Samba[edit]
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.
- [global]
- workgroup = WORKGROUP
- server string = SERVER
- interfaces = eth1
- bind interfaces only = Yes
- map to guest = Bad User
- hosts allow = 10.0.44., 127.
- [export]
- path = /export
- 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
pxelinux.cfg[edit]
LABEL Windows PE kernel memdisk initrd winpe.img
Might have to append "raw".