Multiboot UEFI USB Drive

I find that having my recovery tools on a USB drive that can account for most scenarios that i find myself repairing is extremly handy. Having a fast USB key is also important as with the larger tools like MS DART and installing an OS, having a fast USB key makes things move alot faster than some of the cheap and cheerful USB sticks around.

The tools I regularly use:

  • MS Dart - very useful for repairing boot files after cloning partitions
  • Gparted live, great for cloning partitions and disk partitioning in general. Now has NVMe support as well which will come in handy when migrating to a NVMe drive without re-installing the OS.
  • Windows 10 x64 Setup 

The USB key I currently use is setup to boot BIOS/mbr with grub4dos, With all the new PC's around now with UEFI firmware its overdue to update the tool kit to handle the newer systems.

Booting UEFI Mode

For UEFI mode I'll be using the boot files the Gparted Live utilizes, from Grub we will chain load the UEFI Windows Boot Manager to take care of booting DART and Windows 10 install.

GRUB Config file /EFI/boot/grup.cfg the main entries.

menuentry "GParted Live (Default settings)"{
search --set -f /live/vmlinuz
linux /live/vmlinuz boot=live union=overlay username=user config components quiet noswap noeject ip= net.ifnames=0 nosplash
initrd /live/initrd.img
}
menuentry "Microsoft Windows 10 x64 UEFI-GPT" {
insmod part_gpt
insmod fat
insmod search_fs_uuid
insmod chain
search --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 F2B2-2F83
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}

Note: You need to find the UUID for the USB drive to be able to chainload the windows boot manager, the easiest way to find this is to boot GParted Live and look at the information for the USB drive. Gparted reports the UUID and this is used in the above search line and will be different for each USB drive.

  • Copy bootmgfw.efi from C:\Windows\Boot\EFI to USB:/EFI/Microsoft/Boot/bootmgfw.efi
  • Edit Grub.cfg for chain loading bootmgfw.efi

At this point you can UEFI boot Gparted Live or Select the windows Boot manager. To create the boot menu for DART 10 and Windows 10 I created a USB key from the Windows 10 iso and then copied the x64,EFI,Boot folders to the Multiboot USB drive.

BCD Store UEFI

Update the BCD store on the USB key located here: /EFI/Microsoft/boot/BCD

I will be creating two entries both booting UEFI mode

  • Microsoft Diagnostics and Recovery x64 - used for repairing Windows installations when things go wrong.
  • Microsoft Windows 10 x64 Setup UEFI - used to install Windows 10 in UEFI mode and not BIOS/MBR mode

Use BCDEdit to create the following entries in the store

Windows Boot Loader
-------------------
identifier {default}
device ramdisk=[boot]\sources\dart10.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
path \windows\system32\boot\winload.efi
description MS Dart 10 x64 UEFI
locale en-US
inherit {bootloadersettings}
custom:16000060 Yes
osdevice ramdisk=[boot]\sources\dart10.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
systemroot \windows
custom:250000c2 1
detecthal Yes
winpe Yes
ems No

Windows Boot Loader
-------------------
identifier {a4a7fc4a-81b5-11e5-bf73-3cd92b666bca}
device ramdisk=[boot]\x64\sources\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
path \windows\system32\boot\winload.efi
description Windows 10 Setup (64-bit) UEFI
locale en-US
inherit {bootloadersettings}
custom:16000060 Yes
osdevice ramdisk=[boot]\x64\sources\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
systemroot \windows
custom:250000c2 0
detecthal Yes
winpe Yes
ems No



Booting BIOS/MBR Mode (Legacy Mode)

To make the USB key truely versatile I have also set it up to boot traditionally via MBR ( Master Boot Record) this is mode will be for repairing or installing via the legacy BIOS/MBR method.

 

Windows Boot Loader
-------------------
identifier {default}
device ramdisk=[boot]\x64\sources\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
path \windows\system32\boot\winload.exe
description Windows 10 Setup (64-bit)
locale en-US
inherit {bootloadersettings}
osdevice ramdisk=[boot]\x64\sources\boot.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
systemroot \windows
custom:250000c2 0
detecthal Yes
winpe Yes
ems No

Windows Boot Loader
-------------------
identifier {a5c8ee26-72d2-11e5-82c2-3cd92b666bca}
device ramdisk=[boot]\sources\dart10.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
path \windows\system32\boot\winload.exe
description MS Dart 10 x64
locale en-US
inherit {bootloadersettings}
osdevice ramdisk=[boot]\sources\dart10.wim,{7619dcc8-fafe-11d9-b411-000476eba25f}
systemroot \windows
detecthal Yes
winpe Yes
ems Yes


The boot manager store for windows located here /boot/BCD this store is used when booting via the MBR method

Getting Windows 10 x64 to Co-exist

I found out the hard way that WinPE has hard coded paths for the /sources directory. I also found that booting the Windows 10 Install wim looks sequentially through the drives looking for the sources directory. This initially was an issue as Windows 10 Setup would fail to find a suitable drive to install on and prompt for you to load device drivers.

I tired moving the MS DART image to another folder and removing the /sources directory so that Windows 10 setup would search the X:/sources that it mounts and updated the BCD store to find DART images un-bootable - They must be located in /sources This made the Windows 10 Install work but caused the DART images to fail. 

The Workaround was to copy the sources folder out of /x64/sources to /sources leaving the DART WIM files also in /sources. It may be possible to do it the other way around and store the Dart images in /x64/sources and remove the root /sources folder but i have yet to try that.

Summary

The end result is a fully functional UEFI and BIOS/MBR booting USB key with Microsoft Diagnostics and Recovery Tools and Windows 10 setup. Installing windows or repairing a Windows installation you need to boot the USB key via the same method that Windows was installed by if repairing or when installing make sure you boot the key by UEFI if you want the new GPT UEFI method or by the legacy MBR if you want the old way.