Monday, 25 March 2019

MPI Tool Kit v0.093 Beta with rEFInd (UEFI-multibooting of different .imgptn files is now possible)

New Betas for UEFI-multiboot support without needing to MBR-boot!

E2B v1.B0i Beta and MPI Tool Pack v0.093v7 Beta will allow you to select any UEFI-bootable .imgPTN file without needing to CSM boot or needing to run SWITCH_E2B on a different Windows system.

Each .imgPTN file must include rEFInd so that when it UEFI-boots, the rEFInd manager is loaded.

You can then choose to boot to the UEFI payload (linux, KonBoot, Windows Installer, etc.) OR boot to WinPE and run SWITCH_E2B.exe where you can choose to load a different .imgPTN file.

The new MakePartImage only fully supports adding a 64-bit WinPE UEFI, but you can add both 32-bit and 64-bit WinPEs using the X4 method or the second partition method (see below). Since pure 32-bit UEFI systems are quite rare, I have not catered for them in MakePartImage.

Outline of new changes:

  • E2B v1.B0i supports the X4 file extension suffix for .imgPTN files - e.g. Ubuntu.imgptnX4fred would cause the file fred to be loaded as partition 4. 'fred' could be another partition image containing a UEFI-bootable version of WinPE (or even a 32-bit version and a 64-bit version).
  • SWITCH_E2B.exe has been revised to recognise X4 file extensions.
  • MakePartImage.cmd has been revised to prompt for rEFInd addition with 10 second timeout.
There are three ways of using this new multi-UEFI feature.

1. Add a second partition to your E2B drive (can be NTFS or FAT32) containing WinPE boot files and ensure all your .imgPTN23 files include rEFInd. When you UEFI boot to rEFInd, it will find the boot file on the 2nd partition (boot files could be both 32-bit and 64-bit). Note that adding EFI boot files to partition 2 may prevent some systems from CSM-booting to the E2B grub4dos menu!

  • PTN1: E2B or .imgPTN partition
  • PTN2: Second partition with WinPE boot files

2. Create one partition image containing your WinPE files and name it 'SWITCH_PE'. Create your payloads with rEFInd added and append an X4 file extension suffix - (e.g. Ubuntu.imgptnX4SWITCH_PE). When the .imgPTNX4 file boots, partition 4 will contain the WinPE boot files that are in the SWITCH_PE image file. The same SWITCH_PE image file can be used for all your .imgPTN files (boot files could be both 32-bit and 64-bit).
e.g.

  • \_ISO\UBUNTU.imgptnX4switche2b - the ubuntu imgptn file containing rEFInd files
  • \_ISO\switche2b  - another partition image containing the WinPE boot files. It can be used by other rEFInd .imgPTN files too, so you only need the one file.


3. Create your FAT32 .imgPTN files and opt to copy the WinPE files in the CUSTOM_PE folder into the image when prompted. This is the most compatible method, but it will obviously add about 400MB to each .imgPTN file. This method is only fully supported using 64-bit UEFI bootable payloads (64-bit WinPE only).

Introduction

Most systems have a UEFI BIOS setting to enable Legacy\CSM mode which allows you to boot to Easy2Boot's grub4dos Legacy-BIOS menu. At present, only a few systems, such as some Intel NUC sticks, are UEFI-only.

However, from 2020 onward, some new (Intel) PCs will start to appear on the market which ONLY  UEFI-boot (no CSM option).

UEFI-only systems

The major problem with E2B is that when you UEFI-boot you can only 'switch-in' a different .imgPTN file using SWITCH_E2B.exe (a 32-bit Windows utility). So if the 'current' image on the E2B drive does not boot to a version of Windows which can run 32-bit apps, then you will need to plug the E2B drive into a different system in order to change the bootable payload.

The MakePartImage script now adds rEFInd to the .imgPTN image file and can also (optionally) add in a WinPE boot.wim file containing a copy of SWITCH_E2B.exe.

This allows you to UEFI-boot and pick one or more bootable EFI files from it's menu or run SWITCH_E2B from WinPE and choose  different .imgPTN file.

UEFI-multiboot

So now you can UEFI-boot to any .imgPTN file and then when finished, boot to mini-WinPE and choose another .imgPTN file. The USB stick will still boot to the CSM menu if you MBR boot from it.

Because the images are all separate and self-contained, they are easy to manage (no need to re-make the USB drive if you want to change or add a new UEFI image).

Typical rEFInd boot menu
  • The large blue-and-white arrow icon will boot to the original payload's UEFI boot file(s).
  • The Easy2Boot icon will boot to E2B Mini-WinPE (SWITCH_x64.wim).
  • The smaller icons will run (in order) MokManager (to enroll keys), rEFInd information, power off, reboot, run BIOS Setup utility, exit to UEFI shell.
  • If you accidentally get thrown into the UEFI boot shell, you can type 'e2b' and press ENTER to boot to the E2B Mini-WinPE.
Easy2Boot Icon launches MiniWinPE10 (Russian_Mini) with SWITCH_E2B

For example...

Say you convert a Clonezilla ISO to a .imgPTN file. By adding rEFInd, we can now UEFI-boot to the Clonezilla EFI boot file or to any other EFI boot file that is on any of the other disks or other partitions that are in the system.

So if we also add our a mini-WinPE  boot.wim file containing SWITCH_E2B, after booting to Clonezilla, we can reboot to our mini-WinPE, run SWITCH_E2B.exe and select a different UEFI .imgPTN file. SWITCH_E2B.exe can be found on the E2B drive in the \e2b folder if it is not inside the WinPE image.

The same applies to a Windows ISO. Using rEFInd we can boot to the Windows boot file or the mini-WinPE boot file to run SWITCH_E2B.exe (there will also be an extra option to boot to SWITCH_E2B Mini-WinPE in the bootmgr menu).

So we could make a Clonezilla.imgPTN file which also contains rEFInd+Mini-WinPE - it would be approx .650MB though...
    OR
We could make a Clonezilla.imgPTN23 file with rEFInd but without Mini-WinPE but keep a Mini-WinPE on the second partition of the E2B drive so we can boot to it using rEFInd. This keeps the size of our image files down.
    OR (recommended)
We could use a Clonezilla.imgptnX4WinPE file containing rEFInd with an X4 extension which will load 'WinPE' as partition 4.

MakePartImage

If FAT32 is selected, MPI will now prompt the user to select rEFInd, rEFImd+WinPE or None.


There is a timeout so that the conversion batch files will still work.

Mini-WinPE

I made a 400MB Win10 x64 PE with WoW64 for 32-bit app support using ChrisR's WinBulder WinPESE10 project. Only four files are needed:
  • \efi\boot\extra\SWITCH_x64.efi  - bootmgr.efi which loads BCD (bootmgfw.efi)
  • \efi\microsoft\boot\BCD - the BCD to boot to SWITCH_X64.wim (included in MPI)
  • \boot\boot.sdi - standard MS file (included in MPI)
  • \sources\SWITCH_x64.wim - mini-WinPE containing SWITCH_E2B.exe
I added the SWITCH_E2B.exe into the wim file (\Users\Public\Desktop) and added a startsw.cmd file to \ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp which ran SWITCH_E2B.exe using a  start command.

  • \Users\Public\Desktop\SWITCH_E2B.exe
  • \Users\Public\Desktop\Reboot.cmd       (contents: wpeutil reboot)
  • \Users\Public\Desktop\Shutdown.cmd  (contents: wpeutil shutdown)
  • \ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\startsw.cmd (contents: start X:\Users\Public\Desktop\Switch_e2b.exe)
Tip: The new MPI ToolKit includes a file called Mount_WIM.cmd. You can drag-and-drop a .wim file onto Mount_WIM.cmd and it will mount it as C:\MOUNT4. You can then modify the files inside the wim file using Explorer and then save the changes. It also allows you to Export and Compress a single image afterwards. You can copy the Mount_WIM.cmd file to your Desktop (Win8/10 with DISM is required). I have found this .cmd script to be much more reliable to use than GImageX. You can quickly test the wim file by copying it to the \_ISO\MAINMENU folder and MBR-boot to it from the E2B Main menu.

The mini-WinPE files can be added to .imgPTN file, or you can add the WinPE files to the second partition on your E2B USB drive (if you have one) and always use a .imgPTN23 file extension so that the second partition is always available.

To use the X4 feature, you would simply drag-and-drop the CUSTOM_PE folder containing your WinPE files onto the MPI_NTFS shortcut to make a 'SWITCH_PE' file (or whatever name you decide to call it).

When adding WinPE into a FAT32 .imgPTN file, if a BCD already exists, then MPI will add an extra entry into it. If there is no BCD in the image then MPI will copy on a new BCD.

Note: The bootmgr.efi must not be patched to use a different BCD file because it will prevent secure booting from working.

The problems...

  1. rEFInd is not signed (if it was signed, it would only boot other signed EFI files), and so if you try to boot on a Secure-Boot UEFI system, it will display an error and then automatically load MokManager. You can then use MokManager to load the \refind.efi file from the USB drive and enroll the certificate into the firmware NVRAM. From then on, you will be able to Secure UEFI-boot to rEFInd and load any 64-bit UEFI payload on that system.
  2. MokManager is unreliable! On some systems it may not work correctly or the keyboard can stop working or it can hang. Also, it is possible to put a 'secure UEFI' system into a state where you cannot get into the BIOS settings menu and change it to boot from the CSM harddisk (e.g. my Lenovo IdeaPad 300!). The only way around this was to boot from a USB to rEFInd and use the menu to load the UEFI BIOS settings menu!
  3. 32-bit UEFI Secure boot is not supported (but you can boot to 32-bit rEFInd and then a 32-bit WinPE on another partition).
  4. The Mini-WinPE needs to be based on Win8\Win10 PE (for USB 3 and modern chipset drivers and partition 2 support on Removable USB flash drives) but must have 64-bit WoW64 in order to run the 32-bit SWITCH_E2B.exe application. Unfortunately, WoW64 adds about 200MB of files to the WinPE OS which increases the size of the boot.wim a lot! This greatly increases the size of each and every .imgPTN file if you add it in to each image file.
  5. I cannot legally distribute Microsoft WinPE with the MPI Tool Kit. The end-user must make their own version.
Currently, I have this all working but the two biggest problems are the large size of the Mini-WinPE (currently 400MB) and how to make it easy for the end user to make their own Mini-WinPE.

However, if the X4 or PTN2 method is used, the size is not a major concern (except it will be slow to load 400MB from USB unless xHCI is enabled in the BIOS).

If the 32-bit VB6 app. SWITCH_E2B.exe was a 64-bit application, then the WoW64 files could be removed from the boot.wim file. This would reduce the size of the boot.wim by at least 50-100MB.

The problem of the creation of the WinPE is partially solved by ChrisR's WinBuilder Win10PESE project. We can remove all unnecessary options and ensuring that max. compression is selected.

Out-of-order partitions

Note that some UEFI systems will not boot from a USB disk if the partitions are not in ascending order:

e.g. if the Ubuntu partition contains a bootx64.efi boot file...

PTN1 FAT32 = \_ISO\MAINMENU\Ubuntu.imgptnX4WinPE  (starts at LBA 20000 on disk)
PTN4 FAT32 = \_ISO\WinPE  (starts at LBA 10000 on disk)

In this case the start of the first partition is after 4th partition (i.e. the partitions are not in order). Some UEFI BIOSes will boot this just fine (e.g. Lenovo IdeaPad 300) others (e.g. Asus PCs) will refuse to show a UEFI boot option!

SWITCH_E2B.exe will attempt to re-order the files for you by moving one of them, but this often takes a while and requires the disk to have a lot of space too!

For this reason, this type of arrangement works best when using a large, fast USB drive.

Three ways to use this new feature

1. Single FAT32 .imgPTN

Each of your .imgPTN files would include rEFInd plus the large x64 boot.wim file for Mini-WinPE.
This is the simplest and most reliable way to UEFI boot because a single FAT32 partition is used.
100% of UEFI systems should boot using this simple setup. The disadvantage is that it adds about 400MB to each imgptn file!

2. PTN2 - Add a second partition to your E2B USB drive

Each of your .imgPTN files should be FAT32 with rEFInd added.
You then add a second Primary partition (NTFS or FAT32) to your E2B USB drive which contains the WinPE boot files.

Now each of your .imgPTN images can access and run the Mini-WinPE on the 2nd partition.
The four files that are required for MiniWinPE UEFI booting are listed below.

For best BIOS compatibility, use an NTFS 2nd partition and make sure a \EFI\Boot\Bootx64.efi file is not present on the 2nd partition - otherwise you might not be able to CSM-boot to the E2B menu on some systems.

3. X4 (recommended) - Single FAT32 .imgPTN + second .imgPTN file containing just the mini-WinPE files

This method should be more reliable than using a permanent second partition, but the two files do need to be in order.

e.g. your payload files include rEFInd but also have an X4 suffix...
\_ISO\LINUX\UBUNTU.imgptnX4MyMiniPE
\_ISO\WINDOWS\WIN10\Win10x64Install.imgPTNX4MyMiniPE
\_ISO\MAINMENU\WinFE.imgptnX4MyMiniPE

All of these images will add another image named MyMiniPE as the 4th Primary partition.
The name after 'X4' can be any name you like.

The X4 file is searched for in this order (using X4MiniPE as an example):
  1. Ptn2: \ISO
  2. (same folder as .imgPTN file)\MiniPE
  3. \_ISO\MiniPE
It is best to place the file on Partition 2 of your E2B USB drive if possible, because the two files will always be in the correct order.

In this way the same file can be used by all of your .imgPTN files.

You can easily make the MyMiniPE file by dropping a folder onto the MPI_FAT32 or MPI_NTFS shortcut which contains the following files:

.\CUSTOM_PE folder contents:
  • \boot\boot.sdi  - standard MS file
  • \EFI\Microsoft\Boot\BCD - modified using BootIce to load \Source\Switch_x64.wim
  • \EFI\Boot\Extra\Switch_x64.efi - standard bootx64 bootmgr efi file renamed
  • \Sources\Switch_x64.wim - your 64-bit WinPE wim file


Changes to E2B

  • E2B's QRUN.g4b will look for the X4xxxxx file extension suffix and add it in as partition 4
  • SWITCH_E2B will now look for the X4xxxxxx file extension suffix and add it in as partition 4
  • The MPI Tool Kit - if you drop an ISO onto the MPI_FAT32 shortcut, it will create a .imgPTN file that includes rEFInd when prompted. In addition, if the CUSTOM_PE folder is present in the MPI folder and it contains a .wim file, it will ask you if you want to include that inside the .imgPTN. If a BCD file already exists, MakePartImage will add an extra entry into the existing BCD for the Mini-WinPE.

Downloads available

  • SWITCHPE - UEF-bootable partition image for use with X4 file extension - copy to \_ISO folder
  • SWITCHPE_russian_mini - Win10PE partition image 260MB with WoW64 and SWITCH_PE
  • CUSTOM_PEv2_Password_is_easy2boot.zip - zipped up CUSTOM_PE folder with wim file
  • MPI_Tool_Pack_Plus_CloverLite_093.zip - latest MPI with rEFInd
  • Easy2Boot_v1.B0k_Beta.zip - latest E2B
A complete 400MB CUSTOM_PE.zip file is also provided (password is 'easy2boot') which contains a sample SWITCH_X64.wim and SWITCH_x64.efi file - just replace the CUSTOM_PE folder with this one if you want to add a UEFI-bootable x64 WinPE to your .imgPTN files. The russian_mini is a replacement for SWITCHPE but is much smaller.

As well as the WinPE files, you can add extra efi payloads by adding a folder below the \EFI folder, e.g. add the MemTest86 EFI boot folder, e.g. \EFI\Memtest86\*.

Make an 'X4' file (recommended)

Alternatively, drag-and-drop the CUSTOM_PE folder onto the MPI_NTFS shortcut to make an X4 file - e.g. SWITCHPE (file with no extension). Then copy SWITCHPE to the \_ISO folder. Now make a .imgPTN file using the MPI_FAT32 shortcut (don't add WinPE when/if prompted). Rename the file to xxxxxxx.imgptnX4switchpe so that SWITCHPE is loaded as partition 4.

The name of the new file can be anything you like (the X4 name must be at end of the extension and must have no extension). The X4 file will be looked for at Ptn2:\_ISO first and then in the same folder as the .imgPTN and lastly in the \_ISO folder of the E2B partition.

The smaller the .wim file, the quicker it will get to the WinPE Desktop. A ready-made 250MB partition image containing SWITCH_E2B is available on the Alternate Download site

Feedback

Please let me have your feedback. Beta versions are available here (check for latest version before you report a problem).

A new eBook on UEFI-multibooting with E2B will be available at some later date.

No comments:

Post a comment