📜 ⬆️ ⬇️

Expanding WDS Functionality: Adding Download Capability to UEFI

Hello!


This article outlines the steps you need to follow to add UEFI mode to your WDS.


Those. The instruction in this article assumes that you already have, roughly the following configuration:


1. Windows Server 2012R2 ( ) 2.   DHCP    WDS 3.   WDS 4. IIS 5.      Ubuntu 

Also, here are described the actions that did not bring me the proper result.
I described them, to facilitate the search and save your time.


Foreword


I did it somehow at WDS with a lot of buns, because tired of constantly running around with a bunch of flash drives and rewriting them.


Helped me by the way then these articles:
Add WDS universality
PXE boot menu with System Center Configuration Manager


It looks like this


And everything was fine, new images were added for download, the winPE image was overlaid with new features and everything worked.


But far from all devices support BIOS / Legacy boot mode, or if they support it, its inclusion may be in a very non-obvious place.


Yes, and installing windows in legacy mode, when you can install in UEFI, is not cool.


In the end, I decided to add the ability to download to UEFI, and went to Google.


But I did not find any structured information on how to get a WDS + UEFI worker.
Actually, that's why I decided to write this article.


Before starting, I will describe the problem that took the most time.


When adding UEFI to WDS, the following is possible, a rather not obvious situation:

If you add the boot file to the WDS and when you try to load it on the device
in UEFI, you see the following text:
The selected boot device failed. Press <Enter> to Continue.
Or Boot Device Not Found
But loading in legacy works for you.
Then one of the possible options is the absence of the wdsmgfw.efi file,
along the following path: %WDSpath%\Boot\x64\wdsmgfw.efi


You can C:\Windows\System32\RemInst\boot\x64\wdsmgfw.efi it here: C:\Windows\System32\RemInst\boot\x64\wdsmgfw.efi
Or, if you lack this file for some reason, I uploaded it to google .
For this decision, thanks to the guys from Reddit .


With this problem I killed the most time, because I thought the problem was somewhere in the WDS or DHCP configuration.


I set up policies by adding Vendor Classes (vendor classes) for different architectures, and configuring DHCP options 060, 066, 067. Instructions for configuring DHCP policies.


ASCII architecture for configuring DHCP

PXEClient: Arch: 00000 - BIOS / Legacy
PXEClient: Arch: 00006 - UEFI x86
PXEClient: Arch: 00007 - UEFI x64


I also tried various versions of the .efi boot files .efi


  • syslinux
  • grub 2

I also tried to find a problem in the Event Log.
win + r -> eventvwr -> -> Microsoft -> Windows -> Deployment-Services-Diagnostics


But, as I said above, the problem lay in the wdsmgfw.efi file.
Either I accidentally deleted it myself, or it was not copied during installation.
and configure WDS.


Well, let's get started!


Instruction


Stage 1 - WDS Health Check


Take any device or virtual machine with support for booting in UEFI mode over the network and try to boot.


You should have the following picture:



If so, then great, you can continue.
If not, then look what I wrote in the preface.


Step 2 - Build the iPXE boot file


Run Ubuntu, prepared in advance, open the terminal and insert this line:


 git clone https://git.ipxe.org/ipxe.git ipxe 


Here I would like to make a small note, that you may have to add the packages necessary for compiling C and C ++ in Ubuntu.
I just had them already installed.


Downloaded? - Well!
Now you need to make a configuration file for the assembly.
In the terminal, we write:


 cd ipxe/src gedit chain.ipxe 

And paste into this file, the following code, and then save:


 #!ipxe dhcp chain http://%IP-address-your-IIS-server%/install.ipxe 

Go back to the terminal and start the compilation:


 make bin-x86_64-efi/ipxe.efi EMBED=chain.ipxe 


If everything is in order, then you should get the following output in the terminal:



And the file ipxe.efi , along the path: ipxe/src/bin-x86_64-efi/ipxe.efi
If you for some reason failed to compile on your own,
I attached my file .
It is compiled for download from http://192.168.0.100/install.ipxe


This is all about Ubuntu.


Stage 3 - Adding ipxe.efi to WDS


We take the file that we received in the second stage and copy it along the path:
%WDSpath%\Boot\x64\%your-boot-folder%\EFI\BOOT\
After rename it to BOOTX64.EFI.
This is not necessarily so easy.


Then we start cmd on behalf of the administrator, and we write the following commands:


 wdsutil /set-server /bootprogram:Boot\x64\%your-boot-folder%\EFI\BOOT\BOOTX 64.EFI /architecture:x64uefi  wdsutil /set-server /N12bootprogram:Boot\x64\%your-boot-folder%\EFI\BOOT\BOOTX 64.EFI /architecture:x64uefi 

This will install the resulting file for downloading via WDS.


Check the configuration:


 wdsutil /get-server /Show:Config 


I also copied the ipxe.efi file, renamed it to BOOTIA32.EFI, and configured the boot for it, just in case. architecture:x86uefi
But by and large, this makes no sense, because Bootmgfw.efi file does not support x86


Check what happened.

Great, WDS passes our file for download and it in turn looks for the configuration along the path: http://192.168.0.100/install.ipxe


Stage 4 - Menu Configuration


Go to the root folder of your site.
The default is: C:\inetpub\wwwroot


Create a text file install.ipxe .


And we configure it according to the documentation and your needs.
There is also a Russian-language description of commands.
I used this instruction when configuring my WDS.


Install.ipxe configuration example
 #!ipxe :start menu Please choose an operating system to start/install item --gap Start Win PE item WinPE-x64 WinPE x64 item --gap ipxe shell item shell Drop to iPXE shell choose target && goto ${target} :failed echo Booting failed, dropping to shell goto shell :shell echo Type 'exit' to get the back to the menu shell set menu-timeout 0 set submenu-timeout 0 goto start :WinPE-x64 kernel http://192.168.0.100/wimboot initrd http://192.168.0.100/peSE/Boot/bcd initrd http://192.168.0.100/peSE/Boot/boot.sdi initrd http://192.168.0.100/peSE/Boot/peSE64.wim boot || goto failed 

About the configuration for downloading winPE can be read here .


Stage 5 - MIME types


After creating the menu and adding all the necessary files to the IIS root folder,
must be given access to them.


Because even if you try to download a file from a browser, you will get an error at its address: HTTP 404.3 - Not Found .


To do this, you need to add MIME types to the IIS control panel, in accordance with
with file extensions that you will have to download via http.


I was not looking for what type of MIME is better suited for this purpose, and asked for application/octet-stream , after which it all worked.


For files that have no extension, use a period.


Like this:



Conclusion


In the end, we get the ability to boot on a local network through UEFI.


If we did everything correctly, then there will be something like this boot selection menu:



If you have the basic tools prepared and you will not bother with the configuration, then it takes about 10-20 minutes to implement this feature.
It took me 2 working days because I had to google a lot.


Successful implementation!


Thank you for your attention and many thanks to those people whose articles helped me!
On Habré it: Ingtar and Deeptown .


')

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


All Articles