ipxe / wimboot

WIM bootloader
https://ipxe.org/wimboot
GNU General Public License v2.0
231 stars 42 forks source link

Failing to Extract BCD & boot.sdi #10

Closed PicoMitchell closed 3 years ago

PicoMitchell commented 3 years ago

Awesome to see new releases of wimboot, thanks so much! I'm glad to have to new quiet option for our production boot :-)

I also saw "Extract BCD, boot.sdi, and standard boot font files automatically from the .wim image." in the 2.7.1 release notes, which sounds like an awesome addition. But, I am not sure how to take advantage of that or if I've encountered a bug. I tried simply commenting out my initrd lines in my iPXE menu with the BCD and boot.sdi files, but WinPE fails to load with an error saying that the BCD file is unavailable (photo attached).

Is this a bug, or do I need to supply some argument to wimboot for it extract these files automatically? I double checked that the BCD and boot.sdi files are within \Windows\Boot\DVD\[EFI & PCAT]\ in my wim file.

IMG_1067

mcb30 commented 3 years ago

Simply commenting out or omitting the lines should work and is exactly what happens in the automated test runs - see e.g. https://github.com/ipxe/wimboot/blob/master/test/testwimboot#L69-L76 for the code that generates the script. You can see the corresponding output in the test artifacts (e.g. at https://github.com/ipxe/wimboot/runs/1922794909):

wimboot v2.7.1 -- Windows Imaging Format bootloader -- https://ipxe.org/wimboot

Found initrd at [0x5c258000,0x7fef2074)
Placing initrd at [0x5c345000,0x7ffdf074)
Using qr.txt via 0x5c345078 len 0x6e8
Using boot.wim via 0x5c346078 len 0x23c93ef2
...found WIM file boot.wim
Using winpeshl.ini via 0x7ffda07c len 0x21
Using BCD via 0x7ffdb074 len 0x4000
...patching WIM boot.wim
...patching WIM header at [0x0,0xd0)
...patching WIM qr.txt at [0x23c93ef2,0x23c945da)
...patching WIM winpeshl.ini at [0x23c945da,0x23c945fb)
...patching WIM lookup.copy at [0x23c94600,0x23d35ff0)
...patching WIM lookup.boot at [0x23d35ff0,0x23d36022)
...patching WIM lookup.file at [0x23d36022,0x23d36054)
...patching WIM lookup.file at [0x23d36054,0x23d36086)
...patching WIM boot.copy at [0x23d36088,0x241df330)
...patching WIM directory at 0x23d470b0 from [0x23db1b40,0x23ddd310)
...patching WIM dir.file at [0x241df330,0x241df3d6)
...patching WIM dir.file at [0x241df3d8,0x241df47e)
...patching WIM \Windows\System32 at [0x241df480,0x2420ac50)
...patching WIM dir.subdir at [0x23d470c0,0x23d470c8)
...patching WIM length 0x23c93ef2->0x2420ac58
...found file "\Windows\Boot\PXE\bootmgr.exe"
Using bootmgr.exe via 0x53860 len 0xa3538
...extracted bootmgr.exe
...found file "\Windows\Boot\DVD\PCAT\boot.sdi"
Using boot.sdi via 0x5394c len 0x306000
...found file "\Windows\Boot\Fonts\segmono_boot.ttf"
Using segmono_boot.ttf via 0x53a38 len 0xaed8
...found file "\Windows\Boot\Fonts\segoen_slboot.ttf"
Using segoen_slboot.ttf via 0x53b24 len 0x14f04
...found file "\Windows\Boot\Fonts\segoe_slboot.ttf"
Using segoe_slboot.ttf via 0x53c10 len 0x1503d
...found file "\Windows\Boot\Fonts\wgl4_boot.ttf"
Using wgl4_boot.ttf via 0x53cfc len 0xbf60
Emulating drive 0x80
Placing initrd at physical [0x5c345000,0x7ffdf074)
Entering bootmgr.exe with parameters at 0x2df80

I'd suggest adding the pause option to the command line so that you can see the equivalent output from your .wim file. You're also welcome to make your .wim available to me privately for debugging, if that's viable.

PicoMitchell commented 3 years ago

Thanks for the quick reply. From the output with the pause option, it looks like wimboot is not finding the DVD directory in my wim.

When double checking my wim, I just realized that I made a foolish mistake before while I was "multi-tasking". I checked that the DVD directory with BCD and boot.sdi files existed in my installation wim, instead of my WinPE wim...

For some reason, my WinPE wim actually does not have a DVD folder. I'm not sure why since this was built directly from the latest ADK.

I will investigate that, and close this issue since wimboot really just couldn't load the wim since these required files were not available.

PicoMitchell commented 3 years ago

It looks like the source winpe.wim from the latest ADK simple does not have the DVD directory with the BCD and boot.sdi files.

I will just add a step to my custom WinPE building script to copy this DVD directory into WinPE from my running OS so that I can simply the wimboot configuration.

mcb30 commented 3 years ago

It looks like the source winpe.wim from the latest ADK simple does not have the DVD directory with the BCD and boot.sdi files.

Do the BCD and boot.sdi files appear anywhere within the ADK-generated .wim? If so, we could add them to the search paths.

PicoMitchell commented 3 years ago

I am not finding the files anywhere obvious within the Boot folder, but I am not sure of all the other places I could look. I will try to search for them with PowerShell and let you know.

PicoMitchell commented 3 years ago

I did not find anything with Get-ChildItem '[WinPE-mount-path]' -Include 'BCD', 'boot.sdi' -File Recurse

I am also getting permissions errors when trying to copy \Windows\Boot\DVD into [WinPE-mount-path]\Windows\Boot so I'll have to come back to this later and leave my wimboot config as is for now.

PicoMitchell commented 3 years ago

For more context for anyone that stumbles onto this issue...

With WinPE from the ADK, the BCD and boot.sdi files are outside of the WinPE wim because they are put into a folder along side the wim by the copype command. copype creates a directory structure that is intended to be put onto a USB drive with the MakeWinPEMedia.cmd batch file that comes with the ADK. The BCD and boot.sdi end up in a "media\Boot" directory while the WinPE wim is in "media\sources\boot.wim".

In the end, I think this just give me another reason to look into basing my installer on WinRE instead of WinPE. WinRE can be extracted from the full OS wim and does include the BCD and boot.sdi files in the "\Windows\Boot\DVD" locations that wimboot will look for. The other benefit to WinRE that I have wanted to investigate is Wi-Fi support. Here is a good tutorial about replacing WinPE with WinRE: https://msendpointmgr.com/2018/03/06/build-a-winpe-with-wireless-support/

The only downside to WinRE vs WinPE is that it's a bit bigger. The base WinPE is 260 MB and the base WinRE is 400 MB. After installing PowerShell and a few other things to both, my equivalent WinPE ends up at 440 MB and WinRE at 550 MB. Not too bad in the end if Wi-Fi ends up working and it simplifies the iPXE/wimboot configuration.

mcb30 commented 3 years ago

The only downside to WinRE vs WinPE is that it's a bit bigger. The base WinPE is 260 MB and the base WinRE is 400 MB. After installing PowerShell and a few other things to both, my equivalent WinPE ends up at 440 MB and WinRE at 550 MB. Not too bad in the end if Wi-Fi ends up working and it simplifies the iPXE/wimboot configuration.

550MB sounds pretty reasonable, especially since wimboot will now make use of system RAM above 4GB. Might it be worth creating a "hello world" WinRE tutorial similar to https://ipxe.org/howto/winpe?

PicoMitchell commented 3 years ago

550MB sounds pretty reasonable, especially since wimboot will now make use of system RAM above 4GB. Might it be worth creating a "hello world" WinRE tutorial similar to https://ipxe.org/howto/winpe?

Totally, and the fact that you can easily extract if from the full OS wim makes it more accessible (especially on Linux) than having to use the ADK to get WinPE.