Notre blog en mousse \o/ - Mot-clé - winpe2024-03-01T10:31:54+01:00Les Lamas !urn:md5:16d806c26b4faf0eabfff608393c3d26DotclearInstaller Windows 10 depuis un PXE Linuxurn:md5:6fdd873b270477166755be876d08da5d2018-04-30T16:09:00+02:002018-04-30T15:20:28+02:00RulianeAdministrationlinuxlivemicrosoftpxesevenwindowswinpe <p>Un certain temps s'est écoulé depuis la rédaction de <a href="https://www.leslamas.net/index.php?post/2012/07/07/Installer-Windows-depuis-un-serveur-PXE-Linux" hreflang="fr">ce billet</a> expliquant comment installer Windows sur un PXE Linux. Il existe désormais une méthode plus simple grâce au bootloader <a href="http://ipxe.org/wimboot" hreflang="en">wimboot</a>, développé par le projet iPXE.<br />
<br />
Sur un machine sous Windows, installer le Windows 10 ADK (Assessment and Deployment Kit). Copier les éléments suivants dans un répertoire acessible en TFTP :<br /></p>
<ul>
<li>C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\Media\Boot\boot.sdi</li>
<li>C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\Media\Boot\BCD</li>
<li>C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\en-us\winpe.wim</li>
<li><a href="http://git.ipxe.org/releases/wimboot/wimboot-latest.zip">wimboot</a></li>
</ul>
<p><br />
Ajouter un fichier "startnet.cmd" avec la liste des commandes à lancer au démarrage :<br /></p>
<pre>
wpeinit
net use Y: \\boot\windows10 /user:user pass
Y:\setup.exe
</pre>
<p><br />
Pour du PXElinux, ajouter une entrée dans le menu :<br /></p>
<pre>
# Installation de Windows 10
LABEL win10installer
MENU LABEL Installation de Windows 10 Professionnel 64 bits
COM32 linux.c32
APPEND win10installer/wimboot initrdfile=win10installer/startnet.cmd,win10installer/BCD,win10installer/boot.sdi,win10installer/boot.wim
</pre>
<p>Attention : il faut avoir une version de pxelinux assez récente pour pouvoir lancer wimboot !</p>Installer Windows depuis un serveur PXE Linuxurn:md5:a86d3b9aa8d21f380f8806a27ba0a69d2012-07-07T20:50:00+02:002014-02-24T20:36:19+01:00RulianeAdministrationdisklessinstallationpxesevenwindowswinpe<p>Voyons comment installer Windows depuis un démarrage PXE. Ceci revient en fait à lancer l'installation de Windows (7 par exemple) depuis un environnement WinPE personnalisé de la manière suivante :<br />
- intégration du pilote Realtek Gigabit PCIe, de plus en plus répandu et indispensable pour lancer l'installation par le réseau ;<br />
- une fois WinPE chargé, montage du media en CIFS contenant le répertoire "source" du média d'installation et lancement de l'assistant.</p> <p>Cette méthode et ce billet sont très largement inspirée de ce très bon billet : <a href="http://doomclaw.de/index.php/2009/08/18/installing-windows-7-with-a-pxe-boot-server/trackback/" hreflang="en" title="Installing Windows 7 with a PXE boot server">Installing Windows 7 with a PXE boot server</a>. Il consiste essentiellement en quelques modifications du script.<br />
<br /></p>
<ul>
<li><a href="http://www.microsoft.com/fr-fr/download/details.aspx?id=5753" title="WAIK pour Windows 7">Télécharger</a> et installer le Windows Automated Installation Kit (WAIK) ;<br /></li>
<li><a href="http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&PNid=13&PFid=5&Level=5&Conn=4&DownTypeID=3&GetDown=false#1" hreflang="en">Télécharger</a> le pilote Realtek et le décompresser.<br /></li>
<li>Dans un nouveau fichier (par exemple build.cmd), coller le code suivant après avoir adapté les variables :</li>
</ul>
<pre>
@echo off
cls
REM Variables
echo Setting variables ...
REM the path to your WAIK installation
set WAIKPath=%ProgramFiles%\Windows AIK
echo Set WAIK directory to %WAIKPath%.
REM possible values are: x86, amd64 and ia64
set ARCH=amd64
echo Set architecture to %ARCH%.
set PEPath=C:\winpe_%ARCH%
echo Set temporary working directory for Windows PE to %PEPath%.
set TFTPPath=C:\tftp\Boot
echo Set TFTP boot directory to %TFTPPath%.
set CIFSShare=\\boot\seven_x64
echo Set CIFS share containing the media to %CIFSShare%
set AdditionalDriver=C:\GBE\64\rt64win7.inf
echo Set driver to be added to %AdditionalDriver%
set BCDStore=%TFTPPath%\BCD
echo Set BCDStore to %BCDStore%.
echo All variables set!
echo.
REM Environment check
echo Checking for clean environment...
if not exist "%WAIKPATH%" set NoWAIK=1 && goto :end
if not exist "%WAIKPath%\Tools\PETools\%ARCH%" set NoARCH=1 && goto :end
if exist %PEPath% echo Temporary working directory not empty! Need to remove && rd %PEPath% /S
if exist %PEPath% echo Temporary working directory still not empty! Trying again ... && cd "%WAIKPath%\Tools\%ARCH%" && imagex /unmount %PEPath%\mount && rd %PEPath% /S /Q
if exist %PEPath% set NotClean=1 && goto :end
if exist %TFTPPath% echo TFTP boot directory not empty! Need to remove && rd %TFTPPath% /S
if exist %TFTPPath% set NotClean=1 && goto :end
echo.
echo Starting real work now ...
cd "%WAIKPath%\Tools\PETools"
echo Copying PE-Files ...
call copype %ARCH% %PEPath%
imagex /mountrw %PEPath%\winpe.wim 1 %PEPath%\mount
echo Personnalisation de l'environnement WinPE
echo net use y: %CIFSShare% >> "%PEPath%\mount\Windows\System32\startnet.cmd"
echo y:\setup.exe >> "%PEPath%\mount\Windows\System32\startnet.cmd"
dism /image:%PEPath%\mount /add-driver /driver:%AdditionalDriver%
md %TFTPPath% > NUL
copy %PEPath%\mount\Windows\Boot\PXE\*.* %TFTPPath% > NUL
copy "%WAIKPath%\Tools\PETools\%ARCH%\boot\boot.sdi" %TFTPPath% > NUL
echo Creation du BCD...
cd %PEPath%\mount\Windows\System32
bcdedit -createstore %BCDStore%
bcdedit -store %BCDStore% -create {ramdiskoptions} /d "Ramdisk options"
bcdedit -store %BCDStore% -set {ramdiskoptions} ramdisksdidevice Boot
bcdedit -store %BCDStore% -set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi
REM Tokens=3 sur un WAIK en anglais
for /f "Tokens=2" %%i in ('bcdedit /store %BCDStore% /create /d "Windows 7 Install Image" /application osloader') do set GUID=%%i
bcdedit -store %BCDStore% -set %GUID% systemroot \Windows
bcdedit -store %BCDStore% -set %GUID% detecthal yes
bcdedit -store %BCDStore% -set %GUID% winpe yes
bcdedit -store %BCDStore% -set %GUID% osdevice ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
bcdedit -store %BCDStore% -set %GUID% device ramdisk=[boot]\Boot\winpe.wim,{ramdiskoptions}
bcdedit -store %BCDStore% -create {bootmgr} /d "Windows 7 Boot Manager"
bcdedit -store %BCDStore% -set {bootmgr} timeout 30
bcdedit -store %BCDStore% -set {bootmgr} displayorder %GUID%
cd "%WAIKPath%\Tools\PETools"
imagex /unmount /commit %PEPath%\mount
copy %PEPath%\winpe.wim %TFTPPath%
goto :exit
:end
if %NoWAIK%=1 echo "Your WAIK directory was not found. Execution aborted." && pause && goto :exit
if %NoARCH%=1 echo "Your Architecture doesn't seem to be right. Or at least it is not known by your WAIK installation. Execution aborted." && pause && goto :exit
if %NotClean%=1 echo "Your environment was not clean. Execution aborted." && pause && goto :exit
:exit
</pre>
<p><br /></p>
<ul>
<li>Démarrer la console ("Deployment Tools Command Prompt") <strong>en administrateur</strong> et lancer le script build.cmd. Cela génère dans %TFTPPath% plusieurs fichiers à copier dans un répertoire "Boot", lui-même à la racine du serveur TFTP.<br /></li>
</ul>
<p><br /></p>
<ul>
<li>Ajouter le remapping suivant grâce à l'option -m de tftpd-hpa :</li>
</ul>
<pre>
rg \\ /
</pre>
<p><br /></p>
<ul>
<li>Il faut créer le lien symbolique suivant dans <racine TFTP>/Boot :</li>
</ul>
<pre>
ln -s pxeboot.n12 startrom.0
</pre>
<p><br /></p>
<ul>
<li>Ajouter une entrée dans le fichier <racine TFTP>/pxelinux.cfg/default :</li>
</ul>
<pre>
LABEL winpe
MENU LABEL Installation de Windows 7 64 bits
KERNEL Boot/startrom.0
</pre>
<p><br />
<br /></p>
<p>EDIT 24/02/2014 : correction de quelques erreurs dans le script.</p>