145 - Install Windows directly from an ISO file using iPXE wimboot (MBR\UEFI + grub2\grub4dos)

This method allows you to directly boot from a number of different unmodified Windows Install 7/8/10 ISOs on a bootable USB drive AND then run Setup to install Windows to a system.
No files need to be extracted from the ISO - just copy the ISO file and boot!
  • Legacy, UEFI or PXE boot is supported.
  • The ISO is automatically mounted as a virtual drive so Setup can find and use the Install.wim\esd file.
  • 2GB or more RAM is required to be in the system (it may fail to work if not enough RAM is available).
  • The Windows Install ISO file does not need to be modified in any way.
I will describe here only the outline process so that you can see how it is done. Easy2Boot uses a similar (but not identical) process when MBR-booting.

Example grub2 menus are also provided (grub4dos only MBR boots, grub2 will MBR and UEFI32 and UEFI64 boot).

Process in outline:

  1. Add Windows Install ISO to a grub4dos or grub2 bootable USB drive
  2. Add a menu for grub4dos\grub2
  3. The menu uses wimboot to boot to files inside the ISO
  4. Add in a null.cfg file which contains the full path of the ISO (except for the drive letter)
  5. The menu also injects a startnet.bat file and winpeshl.ini file
  6. For MBR booting we swap BIOS device hd0 with hd1 so that Windows does not think the boot drive is the USB drive (it may refuse to install Windows to a Removable USB drive or Setup may install the Windows boot code to a USB hard disk if we don't do this).
  7. When the grub2\grub4dos menu is picked, here is what happens...
    1. The ISO is mounted (by grub4dos as a CD device using map or by grub2 as a loop device)
    2. wimboot will load the boot.wim, boot.SDI and BCD from the mounted ISO into RAM
    3. wimboot injects into the boot.wim\X: RAM drive a null.cfg file which contains the file path of the ISO
    4. wimboot injects into the boot.wim\X: RAM drive a winpeshl.ini and startup.bat file
    5. The boot.wim file is booted to by wimboot via bootmgr+BCD and startup.bat runs
    6. startup.bat finds the USB drive and installs ImDisk (which is also located in a folder on the USB drive somewhere)
    7. startup.bat finds the null.cfg file in X:\Windows\System32 and from this we can determine the name of the ISO that we need to load
    8. startup.bat uses ImDisk to load the ISO as drive Y: from the USB drive
    9. startup.bat runs X:\Setup.exe which will now be able to find the \sources\install.wim file on the Y: virtual DVD drive mounted by ImDisk
If required, we can also inject an XML file into the X:\Windows\System32 folder and specify this as the unattend file when we run setup.exe. This will cause Setup to be automated.

For MBR-bootong, it is necessary to swap the BIOS drives 0 (USB drive) and 1 around so that Windows will think the 'boot' drive is the internal hard disk and not the USB drive - otherwise Windows will refuse to install the boot code (and the Windows OS) to the first internal hard disk.

You can use VBox+VMUB to test (see Tutorial 4) but the grub2 drivemap command can cause WinPE to hang and not boot in a VM.

Example grub2 MBR menu:

menuentry "WIN10 Install" --unrestricted --class Windows {
set isoname=win10.iso
loopback loop /$isoname
linux16 /wimboot/wimboot
initrd16 \
newc:bcd:(loop)/boot/bcd \
newc:null.cfg:/wimboot/null.cfg \
newc:winpeshl.ini:/wimboot/winpeshl.ini \
newc:startup.bat.sdi:/wimboot/startup.bat \
newc:boot.sdi:(loop)/boot/boot.sdi \
drivemap -s hd0 hd1

Note: filenames defined after newc: must not be bigger than 31 characters or wimboot will fail.

Also grub is case sensitive so beware! - e.g. /Boot/boot.sdi instead of /boot/boot.sdi.

wimboot will try to locate a suitable bootmgr or bootxxx.efi boot file, so you don't usually need to specify one.

You can also add in bootmgr.exe or bootmgr or bootx64.efi/bootmgfw.efi files if the wim file does not contain a suitable file (copy the files to the \wimboot folder)

iPXEwimboot is used for MBR booting but a special grub2 (unsigned, non-secure) version of grub2 with wimboot.mod is required for UEFI-booting.

Example MBR grub4dos menu:

title Install Windows10x64UK_Oct_2018 using wimboot method
map /Windows10x64UK_Oct_2018.iso (0xff)
map --hook
root (0xff)
# the root path now points to the files inside the ISO file
# hd0,0 is the USB drive that we booted from
kernel (hd0,0)/wimboot/wimboot
initrd @null.cfg=/wimboot/null.cfg @startup.bat=(hd0,0)/wimboot/startup.bat @winpeshl.ini=(hd0,0)/wimboot/winpeshl.ini @bcd=/boot/bcd @boot.sdi=/boot/boot.sdi @boot.wim=/sources/boot.wim
map (hd0) (hd1)
map (hd1) (hd0)
map --hook

IMPORTANT: order of the files in the initrd line seems to be important, the bcd and .wim file should be the last files loaded for the MBR version of wimboot.

On our USB drive we have a \wimboot folder:
null.cfg (contains the line installiso=xxxxxxxxx where xxxxxxxxx is the path and filename of the ISO using forward slashes)
\(the windows install iso)

Example winpeshl.ini

Adding a 'Windows Install from ISO' menu to the E2B grub2 menu system

Set up your E2B drive with a second partition and the E2B grub2 menu files FIRST, then switch to the .imgPTN23 file so that the first partition contains the standard grub2 boot menu system files and the second partition contains your grub2 menu folders (e.g. \_ISO\MAINMENU, etc.) and then...

The following windows_install.grub2 menu text file can be added to the \_ISO\MAINMENU folder on the 2nd partition.
  1. Download the grub2_wimboot files - extract it onto the root of the 2nd partition so you have a new \wimboot folder

  2. Download the windows_install.grub2 file and copy it to \_ISO\MAINMENU\grub2 folder on the 2nd E2B partition. Rename it as custom_menu.grub2 if using grub2 Beta 10 or later.

  3. Create a new \_ISO\MAINMENU\WINDOWS folder (must be in capital letters) on the 2nd partition and place all your Windows Install ISOs in that folder.
This is for MBR booting

2nd partition (additions)
\wimboot folder
\_ISO\MAINMENU\WINDOWS\ (your windows isos here)

Note: E2B grub2 v10W.imgPTN already includes wimboot and a new Windows Install W menu (you just copy your ISOs to the 2nd partition!) - see next section below...

Add grub2 UEFI + wimboot (using a1ive grub2)

I suggest you use the latest E2B grub2 v10W .imgPTN file - see bottom of this page for instructions.

The following instructions are for the v10A E2B grub2 menu system and is more difficult to set up...

A1ive has added a wimboot grub2 module into his special version of grub2 (unsigned).

1. Download the grub2 UEFI zip file
2. Extract the files to the \EFI\BOOT folder on the first FAT32 partition (after switching in the E2B grub2 .imgPTN file)
3. Use the windows_install.grub2 menu file (copy to \_ISO\MAINMENU\grub2 folder)
4. Place all your Windows Install ISO files in the \_ISO\MAINMENU\WINDOWS folder - must end in .ISO or .iso.
5. Add this line into one of the customX_menu.grub2 files at the very bottom to add in the windows menu

source $isofpath/grub2/windows_install.grub2

The E2B grub2 menu system will automatically add-in any customX_menu.grub2 files but the source line is required so that it adds in the windows_install.grub2 menu (or rename it as custom3_menu.grub2 instead if you wish),

The Windows ISOs will be automatically added into the main grub2 menu when you boot. If you have placed Windows Install ISOs in the \_ISO\MAINMENU\WINDOWS folder, they should be listed in the grub2 menu when you boot.

The ISO filename can contain spaces. It must end in .ISO or .iso (case sensitive - so not .ISo for instance).

Standard Microsoft dual-architecture Install ISOs are supported, x64 will be used if the CPU is a 64-bit processor.

For MBR-booting, the menu may run bootmgr and then hang on a Virtual Machine due to the drivemap command - so test on a REAL SYSTEM if you have boot problems on a VM.



#$isofpath e.g. (hd0,msdos2)/_ISO/LINUX - use only in if [ -e tests
#$root2 e.g. (hd0,msdos2) partition containing payload files
#$root e.g. hd0,msdos1 boot partition with grub2 on it
#$root2uuid e.g. 1234-2123-33 (uuid of $root2)

#Special variables: MBR EFI MBR32 MBR64 EFI32 EFI64 BIT32 BIT64 FAT (true if filesystem on ptn2 is FAT)
#if $BIT32 ; then echo 32-bit ; fi
#if ! $BIT64 ; then echo not 64-bit ; fi
#if [ $BIT64 = true and $FAT = true ] ; then echo 64-bit MBR on FAT partititon ; fi
#if [ $BIT64 = true and $EFI = true ] ; then echo 64-bit EFI (same as \$EFI64) ; fi

#CHECK_MNU_FOLDER sets these variables on return - do not use filename and filenamex inside menuentry
#$ip e.g. /_ISO/LINUX
#$ipf e.g. (hd0,msdos2)/_ISO/LINUX
#$isofile e.g. /_ISO/LINUX/xxxx.iso

#supports filenames with spaces

function ListWimBoot {
echo Adding WINDOWS ISO files from $ifp/WINDOWS
for file in $ifp/WINDOWS/*.iso $ifp/WINDOWS/*.ISO; do
if ! test -f "$file"; then continue; fi
regexp -s filename "$ip/WINDOWS/(.*)" "$file"
regexp -s filenamex "$ip/WINDOWS/(.*)(.[iI][Ss][oO])" "$file"
# echo $file
menuentry "${filenamex}" "${filename}" {
#do not use $filename inside menuentry - use $isoname instead!
set isoname="$2" ; CHECK_MNU_FOLDER
#ip, ipf and isofile are now set correctly after CHECK_MNU_FOLDER
loopback loop "${ipf}/WINDOWS/${isoname}"
set pp=
if test -f (loop)/x64/sources/boot.wim; then set pp=/x64; fi
if $MBR32; then
if test -f (loop)/x86/sources/boot.wim; then set pp=/x86; fi
echo Using ${pp}/sources/boot.wim...
set root=$root2
set installiso="${ip}/WINDOWS/${isoname}"
save_env -f /wimboot/null.cfg installiso
# cat /wimboot/null.cfg