User Tools

Site Tools


unattended_installations:windows_pxe

Introduction

Windows Preinstallation Environment (also known as Windows PE and WinPE) is a lightweight version of Windows used for the deployment of PCs, workstations, and servers, or troubleshooting an operating system while it is offline. It is intended to replace MS-DOS boot disks and can be booted via USB flash drive, PXE, iPXE, CD-ROM, or hard disk. Traditionally used by large corporations and OEMs (to preinstall Windows client operating systems on PCs during manufacturing), it is now widely available free of charge via the Windows Automated Installation Kit (WAIK).

Requirements

  • DHCP and PXE server
  • The Windows Automated Installation Toolkit (WAIK)
  • A PC running Windows 7 SP1
  • Windows Installations (DVD or ISO file)
  • Samba4 share

Deployment

Windows Automated Installation Toolkit

In a technician machine (a regular Windows 7 PC) download and install the Windows Automated Installation Toolkit (WAIK).

Download available from:

Create a WinPE ISO image

Create a set of either 32-bit or 64-bit Windows PE files

  • Click Start, and type deployment. Right-click Deployment and Imaging Tools Environment and then select Run as administrator.
  • In the Deployment Tools and Imaging Environment, copy the Windows PE files for the PCs you want to boot:

For 64 bits:

copype amd64 C:\winPE_amd64

For 32 bits:

copype x86 C:\winPE_x86

NOTE:

  • The 64-bit version can boot 64-bit UEFI and 64-bit BIOS PCs.
  • The 32-bit version of Windows PE can boot 32-bit UEFI, 32-bit BIOS, and 64-bit BIOS PCs.

From now on we assume that will deploy 64-bit Windows PE files.

Mount the WindowsPE image

Mount the WindowsPE image to perzonalize later

Dism /Mount-Wim /WimFile:"C:\winPE_amd64\winpe.wim" /index:1 /MountDir:"C:\winPE_amd64\mount"

Add customatizations

Add a startup script

Modify the Startnet.cmd script to include your customized commands (see the following example code). This file is located at C:\winPE_amd64\mount\Windows\System32\Startnet.cmd.

@echo off

echo Trying to load networks drivers...
wpeinit

ping 10.12.1.36 > NUL
if errorlevel 1 goto finish
if errorlevel 0 goto continue

:continue
echo Networks drivers loaded successfully
echo Mounting network drive in Q:

rem Mounting Samba share in q:
net use q: \\10.12.1.36\isos

echo Accessing the shared resource in Q:

q:
menu-os.cmd

:finish
echo Fail to load network driver!!
echo You must to load it manually using 'drvload.exe'
echo Sorry!!

You can also call other batch files or command line scripts from this file.

Note that the code above mount a share located in \\10.12.1.36\ISOs (this is your Windows/Samba server) and run 'menu-os.cmd', this file will be located in mounted shared.

For Plug and Play or networking support, make sure that you include a call to wpeinit in your customized Startnet.cmd script. For more info, see Wpeinit and Startnet.cmd: Using WinPE Startup Scripts.

Wpeinit outputs log messages to c:\Windows\system32\wpeinit.log.

Remove "//press any key to boot from CD or DVD//" message when the ISO boots
del C:\winPE_amd64\ISO\boot\bootfix.bin
Add an app

This step is optional!!

  • Create an app directory inside the mounted Windows PE image.
md "C:\winPE_amd64\mount\windows\<MyApp>"
  • Copy the necessary app files to the local Windows PE directory.
Xcopy C:\<MyApp> "C:\winPE_amd64\mount\windows\<MyApp>"
  • Test the app later by booting Windows PE and running the application from the X: directory.

If your app requires temporary storage, or if Windows PE becomes unresponsive when it runs an app, you may need to increase the amount of temporary storage (scratch space) allocated to Windows PE.

Add temporary storage (scratch space)

This step is optional!!

Windows PE reserves memory on the X: drive to unpack the Windows PE files, plus additional temporary file storage, known as scratch space, that can be used by your applications. By default, this is 512MB for PCs with more than 1GB of RAM, otherwise the default is 32MB. Valid values are 32, 64, 128, 256, or 512:

Dism /Set-ScratchSpace:128 /Image:"C:\winPE_amd64\mount"
Replace the background image

This step is optional!!

If you've got multiple versions of Windows PE, you can set the background image so you can instantly tell which version of Windows PE is running.

Change the security permissions of the Windows PE background image file (\windows\system32\winpe.jpg). This allows you to modify or delete the file:

  • In Windows Explorer, navigate to C:\winPE_amd64\mount\windows\system32.
  • Right-click the C:\winPE_amd64\mount\windows\system32\winpe.jpg file, and select PropertiesSecurity tab → Advanced.
  • Next to Owner, select Change. Change the owner to Administrators.
  • Apply the changes, and exit the Properties window to save changes.
  • Right-click the C:\winPE_amd64\mount\windows\system32\winpe.jpg file, and select PropertiesSecurity tab → Advanced.
  • Modify the permissions for Administrators to allow full access.
  • Apply the changes, and exit the Properties window to save changes.

Finally replace the winpe.jpg file with your own image file.

Add answer file settings

This step is optional!!

Some Windows PE settings can be managed by using an answer file, such as firewall, network, and display settings. Create an answer file, name it unattend.xml, and add it to the root of the Windows PE media to process these settings. For more information, see Wpeinit and Startnet.cmd: Using WinPE Startup Scripts.

Unmount the Windows PE image and create media

  • Unmount the Windows PE image and commit the changes:
Dism /Unmount-Wim /MountDir:"C:\winPE_amd64\mount" /commit
  • Copy the new Windows PE image to C:\winPE_amd64\ISO\Sources
copy C:\winPE_amd64\winpe.wim C:\winPE_amd64\ISO\Sources\Boot.wim
  • Remaster the boot CD:
oscdimg -n -bC:\winPE_amd64\etfsboot.com C:\winPE_amd64\ISO C:\winPE_amd64\winpe_amd64.iso
  • Finally copy the file “winpe_amd64.iso” to your PXE server directory.

Edit WinPE ISO image

If you want to edit a WinPE ISO image previously created just follow the next steps:

Configure Samba4 share

A Windows/Samba share is required to export Windows installations.

First we need to create a directory in /srv to storage Windows installations, for instance:

# mkdir -p /srv/samba-shares/ISOs

Within create a subdirectory for each installation of Windows, ie:

mkdir -p /srv/samba-shares/ISOs/{Win2008R2-ENG,Win2008x32-ENG,Win2008x64-ENG,Win2012R2-VL-ENG,Win7SP1-allver-ESP,Win8.1enterprise-withupdate-x32-ENG,Win8.1enterprise-withupdate-x32-ESP,Win8.1enterprise-withupdate-x64-ENG,Win8.1enterprise-withupdate-x64-ESP,Win8-allver-ESP}

Finally begins to copy the contents of Windows ISO in the right directory.

Configure Samba share

To configure Samba4 share with public access (no require a valid user and password), check the following lines in /etc/samba/smb.conf

security = user
map to guest = Bad User

To add a new share (public share):

  • Edith /etc/samba/smb.conf
  • Add a new share inside:
[ISOs]
  comment = Windows Installations
  path = /srv/samba-shares/WinISOs
  guest ok = Yes
  • To test the config:
# testparm
  • Apply the changes:
# service sernet-samba-smbd restart
# service sernet-samba-nmbd restart
Testing Samba share

To list the shares resources on your Samba server:

# smbclient -L localhost -N

The option -N don't prompt for authentication!!

To access to a public resource:

# smbclient //localhost/ISOs -N -c 'ls'

Windows Intallations Menu

At this point you have configured a public Samba share with many Windows installations inside, so to show the installations menu when boot Windows PE, create the following files in /srv/samba-shares/WinISOs/:

/srv/samba-shares/WinISOs/menu-os.cmd

@echo off

REM Selecting the correct menu
if %PROCESSOR_ARCHITECTURE%==x86 (
menu-os-x32.cmd
) else (
menu-os-x64.cmd
)

/srv/samba-shares/WinISOs/menu-os-x32.cmd

@echo off

echo Starting menu...

:menu
ECHO.
ECHO ...............................................
ECHO       INSTALLATION MENU - DIC UCLV
ECHO ...............................................
ECHO.
ECHO 1  - Install Windows Server 2008 x32 ENGLISH
ECHO 2  - Install Windows 7 SP1 All Version SPANISH
ECHO 3  - Install Windows 8 All Version SPANISH
ECHO 4  - Install Windows 8.1 Enterprise with Update x32 ENGLISH
ECHO 5  - Install Windows 8.1 Enterprise with Update x32 SPANISH
ECHO q  - EXIT
ECHO.

REM Selecting an option
SET /P M=Select an option by a number or 'q' to exit, then press ENTER:
IF %M%==1 GOTO win2008x32
IF %M%==2 GOTO win7sp1allversp
IF %M%==3 GOTO win8allversp
IF %M%==4 GOTO win8.1enterprise-withupdate-x32-eng
IF %M%==5 GOTO win8.1enterprise-withupdate-x32-esp
IF %M%==q GOTO EOF

REM Sections
:win2008x32
ECHO You choose to install Windows 2008 x32 ENGLISH
PAUSE
ECHO Starting setup.exe
q:\Win2008x32-ENG\setup.exe
CLS
GOTO menu

:win7sp1allversp
ECHO You choose to install Windows 7 SP1 All Version SPANISH
PAUSE
ECHO Starting setup.exe
q:\Win7SP1-allver-ESP\setup.exe
CLS
GOTO menu


:win8allversp
ECHO You choose to install Windows 8 All Version SPANISH
PAUSE
ECHO Starting setup.exe
q:\Win8-allver-ESP\setup.exe
CLS
GOTO menu


:win8.1enterprise-withupdate-x32-eng
ECHO You choose to install Windows 8.1 Enterprise x32 with Update ENGLISH
PAUSE
ECHO Starting setup.exe
q:\Win8.1enterprise-withupdate-x32-ENG\setup.exe
CLS
GOTO menu


:win8.1enterprise-withupdate-x32-esp
ECHO You choose to install Windows 8.1 Enterprise x32 with Update SPANISH
PAUSE
ECHO Starting setup.exe
q:\Win8.1enterprise-withupdate-x32-ESP\setup.exe
CLS
GOTO menu


:EOF
ECHO.
ECHO To reload the installation menu type 'menu-os.cmd'
PAUSE
CLS

/srv/samba-shares/WinISOs/menu-os-x64.cmd

@echo off

echo Starting menu...

:menu
ECHO.
ECHO ...............................................
ECHO       INSTALLATION MENU - DIC UCLV
ECHO ...............................................
ECHO.
ECHO 1  - Install Windows Server 2008 x64 ENGLISH
ECHO 2  - Install Windows Server 2008R2 ENGLISH
ECHO 3  - Install Windows Server 2012R2 VL ENGLISH
ECHO 4  - Install Windows 8.1 Enterprise with Update x64 ENGLISH
ECHO 5  - Install Windows 8.1 Enterprise with Update x64 SPANISH
ECHO q  - EXIT
ECHO.

REM Selecting an option
SET /P M=Select an option by a number or 'q' to exit, then press ENTER:
IF %M%==1 GOTO win2008x64
IF %M%==2 GOTO win2008R2
IF %M%==3 GOTO win2012R2VL
IF %M%==4 GOTO win8.1enterprise-withupdate-64-eng
IF %M%==5 GOTO win8.1enterprise-withupdate-x64-esp
IF %M%==q GOTO EOF

REM Sections
:win2008x64
ECHO You choose to install Windows 2008 x64 ENGLISH
PAUSE
ECHO Starting setup.exe
q:\Win2008x64-ENG\setup.exe
CLS
GOTO menu


:win2008R2
ECHO You choose to install Windows 2008R2 ENGLISH
PAUSE
ECHO Starting setup.exe
q:\Win2008R2-ENG\setup.exe
CLS
GOTO menu


:win2012R2VL
ECHO You choose to install Windows 2012R2 VL ENGLISH
PAUSE
ECHO Starting setup.exe
q:\Win2012R2-VL-ENG\setup.exe
CLS
GOTO menu


:win8.1enterprise-withupdate-x64-eng
ECHO You choose to install Windows 8.1 Enterprise x64 with Update ENGLISH
PAUSE
ECHO Starting setup.exe
q:\Win8.1enterprise-withupdate-x64-ENG\setup.exe
CLS
GOTO menu


:win8.1enterprise-withupdate-x64-esp
ECHO You choose to install Windows 8.1 Enterprise x64 with Update SPANISH
PAUSE
ECHO Starting setup.exe
q:\Win8.1enterprise-withupdate-x64-ESP\setup.exe
CLS
GOTO menu


:EOF
ECHO.
ECHO To reload the installation menu type 'menu-os.cmd'
PAUSE
CLS

NOTE: To add or remove Windows installations modify menu-os-x32.cmd or menu-os-x64.cmd

Configure PXE menu

The configuration for PXE menu may look like:

LABEL WinPE for 32 bits systems
    kernel memdisk
    append iso raw initrd=/commons/sysinstall/winpe/winpe_x86.iso

LABEL WinPE for 64 bits systems
    kernel memdisk
    append iso raw initrd=/commons/sysinstall/winpe/winpe_amd64.iso

Where WinPE ISO files are copied in /srv/tftp/commons/sysinstall/winpe/ directory.

Resources

unattended_installations/windows_pxe.txt · Last modified: 2015/06/29 12:10 (external edit)