@
stangmTo sum up the requirements -
An Operating System(s) is PXE booted to prepare the PC. This is currently Linux for some preliminary configuration, followed by WinPE after a reboot.
You would like to eliminate the reboot and do everything via Linux.
The PC
must be set up with two partitions (both formatted with NTFS) -
- 300MB system partition (presumably the active partition containing windows boot files?)
- 100GB primary partition (presumably the partition used for the Windows OS that is being installed/applied)
A Windows OS is installed/applied to the PC after the disk is partitioned.
The native Windows boot loader (BOOTMGR) must be used to boot Windows.
Notes\QuestionsUnless you go with
Suggestion 1 (see below) the first thing to test is whether the required BOOTMGR code can be added to the volume boot record using Linux. This code is automatically added when the partition is formatted in WinPE (versions 2.*/3.*/4.0/5.* anyway). Does formatting the partitions in Linux add this code? Can any third party application be used instead.
If you can't add this code via Linux then you can still try
Suggestion 3.
You mention that Linux is used for
Preliminary configuration - what does this actually mean (what are you doing)?
Suggestion 1Forget about Linux and PXE boot WinPE - using it for the preliminary configuration instead of Linux.
What preliminary configuration are you actually doing? Is it possible to use WinPE instead of Linux for the preliminary configuration? If not, why not?
WinPE can be automated to partition and format the hard drive, apply the wim image and run bcdboot to create all of the required boot files - all without user intervention.
erwan.l has already provided some settings that might speed up network booting WinPE.
Why overcomplicate things?
Suggestion 2Now lets assume that you can't do the preliminary configuration in WinPE and are tied to Linux.
Or maybe you just want to see if it's possible to do everything in Linux anyway. I have no problem with that - we like experiments here at reboot - in fact they're encouraged. After all, as
erwan.l mentioned earlier -
...Surely this is an interesting topic : create a windows system from scratch from linux using wimlib for the last imaging part.
You now have a hell of a lot of work ahead of you deciding which suggestion(s) to experiment with and then testing - you're going to be the one doing the heavy lifting after all.
I'm going to use the grub4dos device syntax in the notes/suggestions below.
- (hd0,0) - 300MB system partition
- (hd0,1) - 100GB primary partition (Windows OS)
- PXE boot Linux.
- Complete your Preliminary configuration
- Partition the HDD
- Format the partitions (NTFS)
- Mark (hd0,1), the Windows partition, as the Active (boot) partition
- Add BOOTMGR code to the (hd0,1) and (hd0,0) volume boot records - that's assuming it wasn't added when the partitions were formatted
- Apply your wim file to (hd0,1)
- Copy BOOTMGR to (hd0,1)
- Copy the generic BCD store (the one that uses boot as path) to (hd0,1)\boot
- Reboot the PC - Windows should boot from (hd0,1)
Once you have finished booting into Windows on (hd0,1) you can run a batch script (as Admin) to automate the following -
- Run diskpart to mark (hd0,0) as active
- Run bcdboot.exe to add the required boot files to (hd0,0)
I'm not sure how to add the BOOTMGR code to the volume boot records using Linux. Also not sure if the very basic generic BCD store will work with newer versions of Windows - you'll need to test this yourself. You will need to generate a different BCD store if the system uses UEFI firmware (hopefully by just making some simple changes to the bcdedit script I posted previously).
I'm not sure if running bcdboot will add BOOTMGR code to (hd0,0)'s volume boot record - hence doing this at the same time as adding the code to (hd0,1).
If you can't add the BOOTMGR code from Linux then you'll have to try suggestion 3.
Suggestion 3- PXE boot Linux.
- Complete your Preliminary configuration
- Partition the HDD
- Format (hd0,1) as NTFS
- Apply your wim file to (hd0,1)
- Copy BOOTMGR to (hd0,1)
- Copy the generic BCD store (the one that uses boot as path) to (hd0,1)\boot
- Reboot - booting to Grub4dos (possibly by PXE booting a Grub4dos floppy disk image?)
- Chainload (hd0,1)\BOOTMGR from Grub4dos (eliminating the need for BOOTMGR code in the VBR) - this should boot Windows
Once you have finished booting into Windows on (hd0,1) you can run a batch script (as Admin) to automate the following -
- Run diskpart to format (hd0,0) - adding BOOTMGR code to the volume boot record
- Run diskpart to mark (hd0,0) as active
- Run bcdboot.exe to add the required boot files to (hd0,0)
The main advantage of this method is that you will
not need to install BOOTMGR code to the volume boot record from Linux - remember I don't know if it's possible to do this. The disadvantage is the need to temporarily install (or PXE boot) a third party boot manager (Grub4dos will definitely do the job - not sure about other alternatives) via the PXE booted Linux.
Other SuggestionsI'm reluctant to mention anything in detail until you can confirm whether BOOTMGR code can be added to the volume boot record using Linux.
erwan.l mentioned a BCD store with a known disk signature - the same disk signature can be written to the local HDD - and possibly changed afterwards to avoid all of your PC's having the same disk signature.
NOTE - The suggestions in this post are also based on posts from erwan.l and Wonko
Regards,
Misty
P.s. I've PM'd Nuno with a request to have this thread split - apologies for continueing with the Off-Topic discussion until then!