📜 ⬆️ ⬇️

Windows Preinstallation Network Download Guide (WinPE)

The pre-installation environment can be used not only to install the operating system, but also as a basis for the system administrator's tools, for example, system recovery, anti-virus treatment, network diagnostics, etc. In this article we will consider the standard WinPE image without adding administrative utilities, as this is a topic for a separate article.

WinPE's network boot sequence, starting with version 2.0, is as follows:
  1. boot network kernel pxeboot.com ;
  2. the network core loads the standard boot manager bootmgr.exe , then the network boot is almost the same as booting from other media;
  3. the boot manager reads the BCD file (boot configuration data), where the configuration information (the location of the boot files) is written, loads the necessary font ( wgl4_boot.ttf ) and the boot.sdi virtual disk boot.sdi , then the WinPE image is loaded;
  4. the boot manager transfers control to the program specified in the path parameter of the BCD file.


To obtain the above files, there is no need to deploy (download and install) Windows AIKs, as stated, for example, here . Also similar is the OEM Preinstallation Kit. We need only the installation disk itself or even its image, in the latter case, your computer should have 7Zip or any other program that will allow you to copy files from ISO and WIM images. So do not waste time downloading and installing Windows AIK. Any architecture compatible distributions of Windows 7, 8 and even 10 will do. For maximum compatibility, it is better to use x86 architecture.

The boot.sdi and bcd files can be taken in the boot directory, here you can also take the entire fonts subdirectory (the font wgl4_boot.ttf is located there), and from the sources directory you need only the boot.wim file. You will need two more files that are located in the boot.wim image. The easiest way is to use the 7Zip graphical file manager, but if you are going to add drivers or packages to your WinPE image, it is best to use the dism utility. Next, we will consider the option with dism, and for those who only need a standard image, we inform you that the necessary files ( pxeboot.n12 and bootmgr.exe ) are located in the windows\boot\pxe . The pxeboot.n12 file differs from the above, pxeboot.com in that it does not require pressing the F12 key.
')
In the case of dism, you will need a computer with Windows 7-10, as on Windows XP dism does not work, as in the other with the bcdedit utility. You can work with these utilities only from an administrator, that is, we find the “Command line” item in the start button, right-click on this item and select “Run as administrator” from the context menu (there are many methods, all of these methods and for all There is no point in listing operating systems, if it didn’t work, try turning on the concept). You can get help with this utility by typing in the running command line:

 dism /? 

For example, we want to make sure that this is the WIM file we need, that is, we need information about the images in the WIM file. To do this, we will get help on the /Get-Wiminfo by typing in the console:

 dism /get-wiminfo /? 

Connect the image with the following command:

 dism /mount-wim /wimfile:<__WIM-> /index:<_> /mountdir:<_> 

I draw your attention to the fact that the path to the WIM file and the connection directory must exist on this computer, and the image index can be found with the /Get-Wiminfo . In the connection directory, we find the windows \ boot \ pxe folder, in which we take two files: pxeboot.n12 and bootmgr.exe .

For those who want to add drivers, you need the following command:

 dism /image:<_> /Add-Driver /driver:<_c_> /recurse /ForceUnsigned 

If you need to add additional packages, such as WMI, HTA, MDAC, NetFX, PPPoE, PowerShell, scripting, etc., you must first find them. For example, install Windows OPK or AIK or ADK. Then execute the command:

 Dism /image:<_> /Add-Package /PackagePath: <____cab> 

Next, you need to disable the image with the command:

 dism /unmount-wim /mountdir:<_> /commit 

Next we look at pxelinux, the PXE network bootloader from the syslinux package, which needs to be downloaded . Unpack the downloaded file, but before we copy the files, let's deal with the root directory. Suppose we use Tftpd32 under the Windows operating system, and the root directory is C:\tftpd32 . Further, we will count all the paths from this directory, but we will not indicate it; moreover, the paths will use forward slash, and not the reverse, as in Windows. That is, if pxelinux.cfg/default specified, then the real path will be C:\tftpd32\pxelinux.cfg\default , and default is the file with no extension. Copy the following files from the directory where syslinux was unpacked into the root directory (that is, C:\tftpd32 ):

The network bootloader is not very different from the parent syslinux project, so much that is applicable when booting from a USB flash drive or CD and vice versa. Create a folder pxelinux.cfg, in which there will be only one file (then with the growth of loading options the number of configuration files will increase) - default, with the following contents:

 UI vesamenu.c32 MENU TITLE PXE Special Boot Menu LABEL bootlocal MENU LABEL ^Boot local disk MENU DEFAULT LOCALBOOT 0 TIMEOUT 80 TOTALTIMEOUT 9000 LABEL winpe MENU LABEL ^WinPE KERNEL pxeboot.0 

The first line sets the graphic character of the menu, the second - the name of the whole menu. Then there are two menu items that are identified as bootlocal and winpe, and the screen will be displayed: Boot local disk and WinPE. As you guessed, the first menu item is the default item and provides local loading, but we are interested in the second item. Some confusion turns out, at first it was told about pxeboot.com , copied pxeboot.n12 , and we registered pxeboot.0 . The fact is that pxelinux has its own requirements for the name of network bootloaders - the extension of such files is .0 , by the way, do not confuse pxeboot.0 , which we took from the WinPE image with pxelinux.0 , taken from syslinux. The second is required to display the menu, and the first is loaded only after selecting the appropriate menu. So, we have to rename pxeboot.n12 to pxeboot.0 and put it in the root folder.

Also in the root folder we have to put bootmgr.exe . Create a boot subdirectory in the root folder where you need to place two files: bcd and boot.sdi and the fonts directory, you also need to create the sources directory, where you copy the boot.wim file. If you are satisfied with the similar location of all the boot files, then the bcd file does not need to be changed. The trick here is that network boot is similar to booting from a CD or USB flash drive.

We can run DHCP and TFTPD (in our example, this is Tftpd32), just check if the settings are correct: the directory is C:\tftpd32 , the file is pxelinux.0 , the choice of network interface, etc. If there are errors or lack of the desired result, see the log viewer. Separately it is necessary to say about computers with the lack of compatibility with the BIOS, that is, only with UEFI. For such computers need other files:

Consider the last question of our article: “What if you need to change the standard location of the WinPE boot files?”. Then we need to make changes in the bcd file. In general, the bcd file is a regular registry hive and can be loaded with the standard regedit, but it will not be convenient to work with binary data, so we will use the bcdedit utility. As with the previous utility, we need administrator mode, so if you close the command window, you need to open it in the same way. Help with the bcdedit utility can be obtained by typing:

 bcdedit /? 

To begin with, we define that in the variable% BCD% there will be the full name of the new BCD file, we will create this file:

 bcdedit /createstore %BCD% 

Next, create a new record of additional parameters required by the boot manager for electronic disc devices:

 bcdedit /store %BCD% /create {ramdiskoptions} /d "Ramdisk options" 

We set two parameters, the second one referring to the% SDI% variable, which contains the path \ boot.sdi relative to the boot device (originally it was \ boot \ boot.sdi):

 bcdedit /store %BCD% /set {ramdiskoptions} ramdisksdidevice boot bcdedit /store %BCD% /set {ramdiskoptions} ramdisksdipath %SDI% 

Create a new entry for WinPE:

 bcdedit /store %BCD% -create /d "WinPE Boot Image" /application osloader 

The result of the last command will be the display of the GUID in curly brackets, then we will designate it as the% GUID% variable. In fact, this could be automated using the FOR command, but then it is more difficult to disassemble them. Set the system root directory parameter:

 bcdedit /store %BCD% /set %GUID% systemroot \Windows 

Set HAL and WinPE definition parameters:

 bcdedit /store %BCD% /set %GUID% detecthal Yes bcdedit /store %BCD% /set %GUID% winpe Yes 

Set the parameters of the device containing the operating system and the device containing the file% WIM%, for example \ windows \ winpe.wim:

 bcdedit /store %BCD% /set %GUID% osdevice ramdisk=[boot]%WIM%,{ramdiskoptions} bcdedit /store %BCD% /set %GUID% device ramdisk=[boot]%WIM%,{ramdiskoptions} 

Create another download manager entry:

 bcdedit /store %BCD% /create {bootmgr} /d "Windows BootManager" 

Set the wait parameter:

 bcdedit /store %BCD% /set {bootmgr} timeout 30 

Set the sequence:

 bcdedit /store %BCD% /set {bootmgr} displayorder %GUID% 

All that BCD file is ready, you can put it in the boot directory of our TFTPD server.

Source: https://habr.com/ru/post/258717/


All Articles