WinPE 2.1: Windows PE 2.1 via PXE booten
1. Einleitung
Microsoft Windows Preinstallation Environment (WinPE) 2.1 ist ein abgespecktes Windows Betriebssystem welches auf Windows Vista SP1 beziehungsweise Windows Server 2008 basiert und von CD, USB-Stick, WDS, PXE oder von der HDD gebootet werden kann. Windows PE wurde für Computerhersteller und Administratoren entwickelt um die Installation von Windows zu automatisieren.
In diesem Tutorial möchte ich Ihnen zeigen wie Sie WinPE 2.1 von einem PXE-Server booten können.
2. Voraussetzungen
Für diese Anleitung benötigen Sie das Windows OEM Preinstallation Kit (OPK) oder das Windows Automated Installation Kit (AIK). Das Windows Automated Installation Kit (AIK) für Windows Vista SP1 beziehungsweise Windows Server 2008 können Sie von der folgenden Webseite herunterladen.
http://www.microsoft.com/downloads/details.aspx?familyid=94BB6E34-D890-4932-81A5-5B50C657DE08&displaylang=de
Hinweis: In der folgenden Anleitung wird das Windows OEM Preinstallation Kit (OPK) verwendet. Sollten Sie das Windows Automated Installation Kit (AIK) verwenden, müssen Sie die Pfadangaben entsprechend anpassen. Das heißt, aus C:\Program Files\Windows OPK\ wird dann C:\Program Files\Windows AIK\.
Nach der Installation öffnen Sie als Administrator die Eingabeaufforderung. Dazu öffnen Sie das Startmenü, klicken auf Alle Programme und anschließend auf Zubehör. Jetzt machen Sie einen Rechtsklick auf die Eingabeaufforderung. Wählen Sie in dem Menü den Eintrag Als Administrator ausführen und bestätigen die Sicherheitswarnung.
3. Benötigte Boot-Dateien sammeln
In diesem Abschnitt werden wir die benötigten Bootdateien zusammen kopieren.
Mit Hilfe des Batch-Skriptes copype.cmd werden die benötigen Dateien für ein WinPE-Image bereitgestellt. Das Skript benötigt die Systemarchitektur und den Zielpfad als Argumente. In diesem Beispiel wollen wir ein Windows PE 2.1 System erstellen welches für Rechner mit x86-Architektur gedacht ist.
C:\>"C:\Program Files\Windows OPK\Tools\PETools\copype.cmd" x86 C:\WinPE_x86
Erstellen Sie jetzt einen temporären Ordner in welchem alle Dateien für den PXE-Server abgelegt werden.
C:\>md C:\tftpboot
C:\>md C:\tftpboot\Boot
C:\>md C:\tftpboot\Boot
Wie Sie sehen erstelle ich auch einen weiteren Unterordner. Da man oft verschiedene Systeme von einem PXE-Server starten möchte, wird hier WinPE 2.1 in einem separatem Ordner abgelegt.
Um an die Bootdateien zu kommen, müssen Sie die Datei winpe.wim mounten.
C:\>"C:\Program Files\Windows OPK\Tools\x86\imagex.exe" /mountrw C:\winpe_x86\winpe.wim 1 C:\winpe_x86\mount
Anschließend kopieren Sie die Dateien aus C:\winpe_x86\mount\Windows\Boot\PXE\ in das temporäre Verzeichnis.
C:\>copy C:\winpe_x86\mount\Windows\Boot\PXE\*.* C:\tftpboot\Boot
Da wir keine weiteren Dateien aus dem WinPE-Image benötigen, sollten Sie dieses wieder unmounten.
C:\>"C:\Program Files\Windows OPK\Tools\x86\imagex.exe" /unmount C:\winpe_x86\mount
Jetzt benötigen Sie nur noch die boot.sdi aus dem OPK- beziehungsweise AIK-Verzeichnis und das WinPE-Image.
C:\>copy "C:\Program Files\Windows OPK\Tools\PETools\x86\boot\boot.sdi" C:\tftpboot\Boot
C:\>copy C:\winpe_x86\winpe.wim C:\tftpboot\Boot
C:\>copy C:\winpe_x86\winpe.wim C:\tftpboot\Boot
Hinweis: Hier wird das original WinPE 2.1 Image verwendet. Sollten Sie weitere Programme und Treiber in das Image implementieren wollen, so tauschen Sie später einfach die winpe.wim auf dem PXE-Server aus.
4. BCD erstellen
In diesem Kapitel werden wir die Boot-Konfiguration mit Hilfe von BCDedit erstellen.
Mit dem ersten Befehl wir die BCD-Datei erstellt in welche die nachfolgenden Einstellungen gespeichert werden.
C:\>bcdedit -createstore C:\BCD
Durch die nächsten Befehle werden die Einstellungen für die Ramdisk eingefügt.
C:\>bcdedit -store C:\BCD -create {ramdiskoptions} /d "Ramdisk Options"
C:\>bcdedit -store C:\BCD -set {ramdiskoptions} ramdisksdidevice boot
C:\>bcdedit -store C:\BCD -set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi
C:\>bcdedit -store C:\BCD -set {ramdiskoptions} ramdisksdidevice boot
C:\>bcdedit -store C:\BCD -set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi
Nachdem die Ramdisk-Einstellungen gespeichert wurden, erstellen Sie einen Eintrag für das WinPE-Image.
C:\>bcdedit -store C:\BCD -create /d "WinPE 2.1 Boot Image" /application osloader
Dieser Befehl sollte nun eine Meldung ausgeben welche wie folgt aussieht.
Der Eintrag wurde erfolgreich in {b1cd684d-7331-11db-b049-dfaf511725d9} kopiert.
Den angezeigten Hex-Wert müssen Sie bei den nächsten Befehlen anstelle von %GUID1% eingeben.
Mit den folgenden Befehlen werden die Einstellungen für das WinPE-Image vorgenommen. Achten Sie bitte besonders auf die Schreibweise der Verzeichnis- und Dateinamen.
C:\>bcdedit -store C:\BCD -set %GUID1% systemroot \Windows
C:\>bcdedit -store C:\BCD -set %GUID1% detecthal Yes
C:\>bcdedit -store C:\BCD -set %GUID1% winpe Yes
C:\>bcdedit -store C:\BCD -set %GUID1% osdevice ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
C:\>bcdedit -store C:\BCD -set %GUID1% device ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
C:\>bcdedit -store C:\BCD -set %GUID1% detecthal Yes
C:\>bcdedit -store C:\BCD -set %GUID1% winpe Yes
C:\>bcdedit -store C:\BCD -set %GUID1% osdevice ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
C:\>bcdedit -store C:\BCD -set %GUID1% device ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
Zum Schluss werden noch die Einstellungen für den Bootmanager eingetragen.
C:\>bcdedit -store C:\BCD -create {bootmgr} /d "Windows Vista Boot Manager"
C:\>bcdedit -store C:\BCD -set {bootmgr} timeout 30
C:\>bcdedit -store C:\BCD -set {bootmgr} displayorder %GUID1%
C:\>bcdedit -store C:\BCD -set {bootmgr} timeout 30
C:\>bcdedit -store C:\BCD -set {bootmgr} displayorder %GUID1%
Wenn alle Befehle erfolgreich ausgeführt wurden, kopieren Sie die erstellte BCD-Datei in den temporären PXE-Ordner.
C:\>copy C:\BCD C:\tftpboot\Boot
Da wir nun alle benötigten Dateien erstellt und zusammen kopiert haben, können Sie den Ordner C:\tftpboot auf ihren PXE-Server übertragen.
5. PXE-Umgebung automatisiert erstellen
Damit Sie die Befehle aus den beiden vorherigen Abschnitten nich von Hand eingeben müssen, stelle ich Ihnen hier mein Batch-Skript zur Verfügung welches Sie nur in eine *.cmd Datei kopieren und dann als Administrator aufrufen müssen.
@echo off
rem
rem Build WinPE2.1_4_PXE
rem
rem 20080720 v1.0 Build WinPE2.1_4_PXE from the source files
rem
set WORKDIR=%~dp0
set KITPATH=
if exist "C:\Program Files\Windows AIK" set KITPATH=C:\Program Files\Windows AIK
if exist "C:\Program Files\Windows OPK" set KITPATH=C:\Program Files\Windows OPK
if "%KITPATH%"=="" goto E_KITPATH
if exist C:\tftpboot rmdir /s /q C:\tftpboot
if errorlevel 1 goto E_DELTMP
if exist C:\winpe_x86 rmdir /s /q C:\winpe_x86
if errorlevel 1 goto E_DELTMP
md C:\tftpboot
if errorlevel 1 goto E_MDOUT
md C:\tftpboot\Boot
if errorlevel 1 goto E_MDOUT
call "%KITPATH%\Tools\PETools\copype.cmd" x86 C:\winpe_x86
cd ..
"%KITPATH%\Tools\x86\imagex.exe" /mountrw C:\winpe_x86\winpe.wim 1 C:\winpe_x86\mount
if errorlevel 1 goto E_MOUNT
copy C:\winpe_x86\mount\Windows\Boot\PXE\*.* C:\tftpboot\Boot
if errorlevel 1 goto E_COPY
"%KITPATH%\Tools\x86\imagex.exe" /unmount C:\winpe_x86\mount
if errorlevel 1 goto E_UNMOUNT
copy "%KITPATH%\Tools\PETools\x86\boot\boot.sdi" C:\tftpboot\Boot
if errorlevel 1 goto E_COPY
copy C:\winpe_x86\winpe.wim C:\tftpboot\Boot
if errorlevel 1 goto E_COPY
bcdedit -createstore C:\BCD
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -create {ramdiskoptions} /d "Ramdisk Options"
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set {ramdiskoptions} ramdisksdidevice boot
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi
if errorlevel 1 goto E_BCD
for /f "tokens=1-3" %%a in ('bcdedit -store C:\BCD -create /d "WinPE 2.1 Boot Image" /application osloader') do set GUID1=%%c
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set %GUID1% systemroot \Windows
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set %GUID1% detecthal Yes
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set %GUID1% winpe Yes
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set %GUID1% osdevice ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set %GUID1% device ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -create {bootmgr} /d "Windows Vista Boot Manager"
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set {bootmgr} timeout 30
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set {bootmgr} displayorder %GUID1%
if errorlevel 1 goto E_BCD
copy C:\BCD C:\tftpboot\Boot
if errorlevel 1 goto E_COPY
if exist C:\winpe_x86 rmdir /s /q C:\winpe_x86
if errorlevel 1 goto E_DELTMP
if exist C:\BCD del C:\BCD
if errorlevel 1 goto E_DELBCD
if exist C:\BCD.LOG del /a C:\BCD.LOG
if errorlevel 1 goto E_DELBCD
if exist C:\BCD.LOG1 del /a C:\BCD.LOG1
if errorlevel 1 goto E_DELBCD
if exist C:\BCD.LOG2 del /a C:\BCD.LOG2
if errorlevel 1 goto E_DELBCD
goto DONE
:E_KITPATH
set MESSAGE=Could not find the OPK/AIK folder!
goto END
:E_DELTMP
set MESSAGE=Could not delete temporary folder!
goto END
:E_MDOUT
set MESSAGE=Could not create output folder!
goto END
:E_MOUNT
set MESSAGE=Could not mount boot.wim!
goto END
:E_COPY
set MESSAGE=Could not copy this file(s) into the output folder!
goto END
:E_UNMOUNT
set MESSAGE=Could not unmount boot.wim!
goto END
:E_BCD
set MESSAGE=BCDEdit failed!
goto END
:E_DELBCD
set MESSAGE=Could not delete temporary BCD files!
goto END
:DONE
cls
set MESSAGE=Done
goto END
:END
echo.
echo %MESSAGE%
echo.
pause
exit
rem
rem Build WinPE2.1_4_PXE
rem
rem 20080720 v1.0 Build WinPE2.1_4_PXE from the source files
rem
set WORKDIR=%~dp0
set KITPATH=
if exist "C:\Program Files\Windows AIK" set KITPATH=C:\Program Files\Windows AIK
if exist "C:\Program Files\Windows OPK" set KITPATH=C:\Program Files\Windows OPK
if "%KITPATH%"=="" goto E_KITPATH
if exist C:\tftpboot rmdir /s /q C:\tftpboot
if errorlevel 1 goto E_DELTMP
if exist C:\winpe_x86 rmdir /s /q C:\winpe_x86
if errorlevel 1 goto E_DELTMP
md C:\tftpboot
if errorlevel 1 goto E_MDOUT
md C:\tftpboot\Boot
if errorlevel 1 goto E_MDOUT
call "%KITPATH%\Tools\PETools\copype.cmd" x86 C:\winpe_x86
cd ..
"%KITPATH%\Tools\x86\imagex.exe" /mountrw C:\winpe_x86\winpe.wim 1 C:\winpe_x86\mount
if errorlevel 1 goto E_MOUNT
copy C:\winpe_x86\mount\Windows\Boot\PXE\*.* C:\tftpboot\Boot
if errorlevel 1 goto E_COPY
"%KITPATH%\Tools\x86\imagex.exe" /unmount C:\winpe_x86\mount
if errorlevel 1 goto E_UNMOUNT
copy "%KITPATH%\Tools\PETools\x86\boot\boot.sdi" C:\tftpboot\Boot
if errorlevel 1 goto E_COPY
copy C:\winpe_x86\winpe.wim C:\tftpboot\Boot
if errorlevel 1 goto E_COPY
bcdedit -createstore C:\BCD
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -create {ramdiskoptions} /d "Ramdisk Options"
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set {ramdiskoptions} ramdisksdidevice boot
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi
if errorlevel 1 goto E_BCD
for /f "tokens=1-3" %%a in ('bcdedit -store C:\BCD -create /d "WinPE 2.1 Boot Image" /application osloader') do set GUID1=%%c
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set %GUID1% systemroot \Windows
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set %GUID1% detecthal Yes
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set %GUID1% winpe Yes
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set %GUID1% osdevice ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set %GUID1% device ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -create {bootmgr} /d "Windows Vista Boot Manager"
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set {bootmgr} timeout 30
if errorlevel 1 goto E_BCD
bcdedit -store C:\BCD -set {bootmgr} displayorder %GUID1%
if errorlevel 1 goto E_BCD
copy C:\BCD C:\tftpboot\Boot
if errorlevel 1 goto E_COPY
if exist C:\winpe_x86 rmdir /s /q C:\winpe_x86
if errorlevel 1 goto E_DELTMP
if exist C:\BCD del C:\BCD
if errorlevel 1 goto E_DELBCD
if exist C:\BCD.LOG del /a C:\BCD.LOG
if errorlevel 1 goto E_DELBCD
if exist C:\BCD.LOG1 del /a C:\BCD.LOG1
if errorlevel 1 goto E_DELBCD
if exist C:\BCD.LOG2 del /a C:\BCD.LOG2
if errorlevel 1 goto E_DELBCD
goto DONE
:E_KITPATH
set MESSAGE=Could not find the OPK/AIK folder!
goto END
:E_DELTMP
set MESSAGE=Could not delete temporary folder!
goto END
:E_MDOUT
set MESSAGE=Could not create output folder!
goto END
:E_MOUNT
set MESSAGE=Could not mount boot.wim!
goto END
:E_COPY
set MESSAGE=Could not copy this file(s) into the output folder!
goto END
:E_UNMOUNT
set MESSAGE=Could not unmount boot.wim!
goto END
:E_BCD
set MESSAGE=BCDEdit failed!
goto END
:E_DELBCD
set MESSAGE=Could not delete temporary BCD files!
goto END
:DONE
cls
set MESSAGE=Done
goto END
:END
echo.
echo %MESSAGE%
echo.
pause
exit
Nachdem Sie das Batch-Skript aufgerufen haben, finden Sie unter C:\tftpboot die erzeugten Dateien, welche Sie auf ihren PXE-Server übertragen können.
6. Linux PXE-Server für WinPE 2.1 konfigurieren
Bevor Sie mit der Konfiguration des PXE-Servers beginnen können, müssen Sie einen DHCP-Server und einen TFTP-Server installieren und konfigurieren.
Wenn Sie diese Voraussetzungen erfüllt haben, fügen Sie in der Datei /etc/dhcpd.conf den folgenden Abschnitt ein.
allow booting;
allow bootp;
next-server 192.168.0.1;
filename "/Boot/pxeboot.n12";
allow bootp;
next-server 192.168.0.1;
filename "/Boot/pxeboot.n12";
Die Option next-server gibt den PXE-Server an und ist in diesem Fall auch die IP-Adresse des DHCP-Servers. Wie bereits hingewiesen, können Sie auch hier anstelle der pxeboot.n12 die pxeboot.com verwenden.
Anschließend erstellen Sie die Datei /etc/remap und fügen den folgenden Abschnitt ein.
re bootmgr\.exe /Boot/bootmgr.exe
rgG [\] /
rgG [\] /
Öffnen Sie jetzt die Datei /etc/xinetd.d/tftp und ergänzen die folgende Zeile.
server_args = -s /tftpboot -m /etc/remap
Jetzt müssen Sie nur noch das Verzeichnis für die Bootdateien erstellen und diese hinein kopieren.
[root@centos5 ~]# mkdir -p /tftpboot/Boot
In diesem Verzeichnis sollten nun die folgenden Dateien existieren.
abortpxe.com
BCD
boot.sdi
bootmgr.exe
hdlscom1.com
hdlscom1.n12
hdlscom2.com
hdlscom2.n12
pxeboot.com
pxeboot.n12
WdsConfig.inf
wdsnbp.com
winpe.wim
BCD
boot.sdi
bootmgr.exe
hdlscom1.com
hdlscom1.n12
hdlscom2.com
hdlscom2.n12
pxeboot.com
pxeboot.n12
WdsConfig.inf
wdsnbp.com
winpe.wim
Damit wären die Vorbereitungen abgeschlossen und Sie können die Server-Dienste starten.
[root@centos5 ~]# service xinetd restart
[root@centos5 ~]# service dhcpd restart
[root@centos5 ~]# service dhcpd restart
Testen Sie anschließend ob WinPE 2.1 vom PXE-Server gestartet wird. Sollte es Probleme geben, überprüfen Sie die exakte Schreibweise der Dateien und Verzeichnisse. Wenn Ihnen hier noch kein Fehler auffällt, können Sie mit Hilfe von tcpdump überprüfen bei welcher Datei der Bootvorgang abgebrochen wird.
[root@centos5 ~]# tcpdump -i eth0
Dieser Eintrag wurde am 04.09.2008 erstellt und zuletzt am 04.10.2013 bearbeitet.
Direkter Link zu dieser Seite: http://www.gtkdb.de/index_10_339.html
[ Zur Startseite ] [ Zur Kategorie ]
© 2004-2021 by Georg Kainzbauer