Friday 16 May 2014

Boot directly from grub4dos to UEFI using Clover!

Clover is a later revision of Tianocore. Both are 'firmware in RAM' replacements for UEFI firmware.
It allows you to boot in MBR\CSM mode and then run Clover which acts as a 'pseudo-UEFI boot manager', allowing you to boot to a UEFI OS from an MBR\CSM boot.

I would like to add this to the CSM menu of Easy2Boot so that users would not have to reboot the system and choose the UEFI: xxxxxx  boot option to boot from the E2B drive (when using .imgPTN image files).

First, I made a FAT32 USB Flash drive using BootDiskUtility.exe. This is a Windows tool that makes a Clover-bootable USB drive for you. Having done this, I found it would not boot under RMPrepUSB's QEMU (which doesn't support 64-bitness and just rebooted) or VirtualBox (text mode menu only) but did boot on a real system to the full GUI menu (see piccy below) - but only on a USB 2.0 port, Clover does not load on my Z87's USB 3.0 ports.

When is EFI not EFI?

Another important (and confusing!) point to note is that 'EFI booting' means MBR booting in 'Clover-speak' and UEFI booting means UEFI booting. If you see a Clover menu option to EFI-boot from a drive - it means MBR\CSM-boot!

This is the 'expected' full-GUI Clover Menu - select the UEFI option for UEFI booting as shown.

This is the text-mode screen I got!

Under VBox, I only got the 'text-mode' screen after making a USB Flash drive using BootDiskUtility.exe to make the USB drive. However, if I ran the USB drive on a real system, I got the correct GUI menu.

I later found that by pressing the 7 key after the first 2 seconds when booting from VBox, I managed to get the correct GUI menu!

To cut a long story short (essential data about Clover is hard to find!), here is how the Clover boot-chain works...

Master Boot Record (MBR)

First in the boot chain, we have the MBR. This is a normal MBR with a partition table, but the code in it seems to be 'special' (see PBR below for why I think this).

The MBR code can be found in a selection of boot0xxx files. You need to replace the boot code in your USB drive's MBR with the boot code from one of these files (but not the partition table).

The MBR code seems to look for and boot a Clover PBR. I found these files for the MBR code:

boot0af - looks for the active partition PBR
boot0ss - 'scan-signature' for AF type - MAC OS extended - seems to work best - no Active ptn needed.
boot0md - multiple drives - searches various drives for an HFS+/MAC OS extended partition - it seems to need the partition to be flagged as Active though!

see here for more (unclear) details! boot0ss still seems to boot from a FAT32 partition the best though!

Partition Boot Record

Moving on to the PBR - this code also seems 'special' in that we cannot just use chainloader ()+1 to boot from it in grub4dos. It seems we MUST go from the Clover MBR code to the Clover PBR code. Therefore both MBR code and PBR code are inter-dependent.

Again, various different Clover PBR code versions are available, these are prefixed as boot1xxx - the PBR code must be patched from byte 3 to byte 86 decimal. In the files produced by the BootDiskUtility, I had these files:

boot1f32 - understands the FAT32 filesystem
boot1f32alt - as above but waits for a key press for 2 seconds
boot1h - understands the HFS+ filesystem for MACs
boot1h2 - as above but waits 2 seconds for a key press

I used boot1f32alt for my experiments. See here for more PBR details.

The next stage in the boot chain is the file that is loaded by the PBR code. By default, this is a file in the root and is called boot.
  • boot - (default) Clover, recent or testing version - rumoured to be the same as boot6 in released versions
  • boot2 - Chameleon
  • boot3 - Clover 32-bit, tested and working version
  • boot6 - Clover 64-bit, tested and working version
  • boot7 - Clover 64-bit with BiosBlockIO driver that works with any controller supported by the BIOS.
Now, here we have a FUNDAMENTAL FLAW (did you spot it?) - the default boot file is boot but Windows uses a folder called boot to hold it's boot files - we cannot have both a file and a folder with the same name on a FAT32 partition! Great thinking guys!

So, assuming I must keep the \boot Windows folder, I had to press 6 or 7 on a real system  to get it to boot to Clover. Eventually I found a way around this though, the PBR code had an ASCII string of
   BOOT<space><space><space> 
near the beginning of the code. I then found that if I modified this to
   BOOT7<space><space>  
it loaded the \boot7 file automatically! I am guessing that when a user presses 7 manually, it just adds the ASCII code for 7 to the end of the 'BOOT' string in memory, and then tries to load that file.

More Files!

Once the \boot(n) code runs, it loads up the rest of Clover from the \EFI\CLOVER folder starting off with
CloverIA32.efi or CloverX64.efi or CloverGUI. Note how these files have the .efi file extension but actually run in MBR mode, whereas normal files such as Microsoft bootx64.efi and bootia32.efi files have the same file extension but run in UEFI mode! Confusing huh?

It then accesses more files under the \EFI\CLOVER folder - see here for more details.

Putting it all together

So after all this - here is my boot chain that works for 64-bit UEFI Windows 8 booting from a single FAT32 partition:

MBR (using boot0md code) ->  PBR (using modified boot1f32alt code) -> \boot7 -> \EFI\CLOVER\CloverX64.efi  ->  Clover menu - \EFI\boot\bootx64.efi ---> Windows UEFI boot.

However, I found that if I chainloaded to /boot0md or /boot0ss in grub4dos, as long as the PBR  had the Clover code in it, it would boot (the md version also needed the partition to be Active too). This meant I can boot to grub4dos in MBR mode to the grub4dos menu and then, from that menu, run Clover - at last!

Grub4dos

So here is my current grub4dos menu for booting directly to UEFI via Clover from grub4dos:
Note it is for FAT32 only and has not been tested on linux, only Windows 8.1 x64 so far.

iftitle [cat --locate="FAT32" --length=10 --skip=0x50 ()+1 > nul] Run Clover UEFI Boot Menu\n Run this if you wish to use Clover to UEFI boot
set CL=0
## boot7 is default boot file
cat --locate="BOOT7" --length=10 --skip=0x58 ()+1 > nul && set /a CL=%CL%+1 > nul
if "%CL%"=="1" echo Information: Clover is already installed to the PBR
## configfile /menu.lst
echo ffffffffff > (md)0x350+1
dd if=(hd0,0)+1 of=(md)0x350+1 > nul
dd if=()/clover/boot1f32alt7 of=(md)0x350+1 skip=87 seek=87 bs=1 > nul
dd if=()/clover/boot1f32alt7 of=(md)0x350+1 count=3 bs=1 > nul
#cat --hex (md)0x350+1 && pause 
if not "%CL%"=="1" cat --locate="SYSLINUX" --length=10 --skip=0x2 ()+1 > nul && pause PROBLEM: SYSLINUX PBR DETECTED - Cannot install Clover to PBR... && configfile /menu.lst
if not "%CL%"=="1" dd if=(md)0x350+1 of=(hd0,0)+1 > nul && pause --wait=2 PBR updated with Clover boot code
chainloader /clover/boot0ss || chainloader /clover/boot0md || chainloader /clover/boot0af

# User can press 2 for 3 for 32-bit UEFI, 6 for 64-bit UEFI or 1 for Chameleon - within 3 seconds
# boot0md gives a boot0 message and is slower - boot0ss is silent with no message

It needs a bit more work and tidying up.

boot1f32alt7 is the modified PBR 512-byte file which will load \boot7 instead of \boot.
The grub4dos menu code works by permanently installing the Clover PBR code into the PBR (it must be FAT32 and it must not have syslinux in the PBR as I assume that if syslinux is in the PBR, it needs it in order to boot to linux - overwriting it would prevent it from booting via syslinux in MBR mode!)
I also moved the boot0xx and boot1xx files to a \Clover folder to keep it tidier.
The user can still press 2, 3 6 or 7 to boot to \boot2, \boot3, \boot6 or \boot7 as these are (currently) still in the root of the FAT32 partition (Edit: in Clover_Pack 002 only boot6 and boot7 are present!).

It would be nice to be able to run syslinux in MBR-boot mode (see below for how I got this to work too).

I now need to test this out on different platforms and different scenarios - hey ho...

A good source of info on Clover is here.

E2B .imgPTN images - boot directly from the CSM menu to UEFI

If you have booted in MBR mode to Easy2Boot, you can select an image partition file (.imgPTN family) and switch partitions to it immediately. However, now you have to reboot the system and select the UEFI firmware boot option for the E2B USB drive.

This is inconvenient and takes time (especially if you are on a server).

I have now added an experimental UEFI Clover boot option to the MakePartImage Tool Pack. Extra menu entries have been added to the CSM menu.lst file to boot Clover ISO files.

You will need MPI v030 and the MPI_Clover_Pack.zip files, available from the EasyBoot download page.

If you add the Clover ISO file(s) to the MakePartImage\Custom\e2b folder before you make your image file using MakePartImage, you will now see one or two extra menu options:


When you select this option it will load Clover. You then need to select the Boot Maintenance Manager option:

and then the Boot from File option:
After that you select the partition and then you need to select the .efi boot file (which will normally be \EFI\boot\bootx64.efi, or bootia32.efi for 32-bit UEFI payloads). It should then boot via UEFI to the efi file on the USB drive. In this way you can directly boot to say, a Windows 8 install image, in UEFI mode without needing to reboot the system and pick the UEFI: USB drive boot menu option.

As you can see, using the Clover menu to boot from, is not exactly convenient, which is why it is not included in the default MPI build. 

Clover is not included as standard because:
1. It doesn't work on all systems - e.g. Z87 systems.
2. It takes up space in the image (and will be in every image you create)
3. You have to go through several steps in the Clover menu to select and boot from an EFI file
4. It dramatically increased the size of the MPI Tool Kit download

This feature is still a work in progress. There are many drivers and other files inside the clover iso files which cannot be accessed via the Clover menu but they could be accessed if they were extracted to the image. I could also reduce the size of the ISO by removing unnecessary files, etc.  As I have only just tried Clover today, I have a lot more learning and experimenting to do!

If you have any suggestions and/or are experienced with Clover, please contact me. Ideally, I would like to be able to boot to the Windows efi files directly from the grub4dos menu...




Wednesday 14 May 2014

E2B - MBR and UEFI booting of large All-In-One Windows Installers

For details about booting to Clover from grub4dos see here.

I was asked recently if it was possible to multiboot large >4GB All-in-One Windows installer ISOs using Easy2Boot in both MBR and UEFI mode.

After some work, I can now answer 'Yes - as long as you use a USB Hard disk for E2B'! - or a USB Flash drive of the 'Fixed Disk' type.

Note: Simone in the Comments below suggests splitting the install.wim file. If this is done with Win 8, you will need to add a special ei.cfg file too, in order to prevent a Microsoft 'licence' error (read the Comments for this blog post for details).

It has always been possible to directly use a AIO ISO on an NTFS-formatted E2B drive for normal MBR-type installs; the problem comes with UEFI installs. UEFI firmware can only boot from FAT filesystems and FAT32 has a 4GB file size limitation. If the Install.wim file is larger than 4GB then we have to place it on an NTFS filesystem.

The new procedure to work around this issue uses two partitions.

Partition 1 - FAT32 - contains all Windows Install files except the Install.wim file
Partition 2 - NTFS  - contains the large \sources\Install.wim file.

You must first make both partition images using MakePartImage. The partition 1 FAT32 image file should be given a filename extension of .imgPTNLBAa. The partition 2 NTFS image file should be given an identical filename but with no file extension at all - e.g.

\_ISO\WIN\Win8AIO.imgPTNLBAa
\_ISO\WIN\Win8AIO

Only the Win8AIO.imgPTNLBAa file will be listed in the Windows menu, but when it is run, the Win8AIO file will be mapped as (hd0,2) and the Win8AIO.imgPTNLBAa file will be mapped as (hd0,0).

In this way, you can boot via MBR or UEFI and install Windows even from an install.wim file larger than 4GB. The latest E2B versions include this feature.

Full step-by-step instructions on how to make the image files are here (scroll down to 'How to add Windows 7/8 installers with >4GB install.wim files').

Some UEFI systems may not like seeing two partitions - please let me know if you try this and what systems you tried it on!

Easy2Boot v1.39 - small bugfix

If you had a FAT32 E2B USB drive and you created a folder with a .  (dot) in the folder name, E2B would give an error during file enumeration. This is now fixed. Thanks to Chase for reporting it!

MPI Tool Pack also has been updated to v1.29. Small fixes for some syslinux ISOs.

Monday 12 May 2014

New PCLinuxOS ISOs and adding an Answer file to Windows Installer .imgPTN images

It seems that PCLinuxOS has had a major Update - see here for details.


There are KDE, LXDE, Full Monty and Mate Desktop versions as well as a KDE MiniMe version - see the downloads page here to download an ISO and try it out on your Easy2Boot USB drive.

If any of you are using .imgPTN partition image files with Easy2Boot of Windows Vista/7/8 installers and want to add an answer file for automated installs, I have added instructions to the Easy2Boot website here (scroll to the bottom of the page).

Saturday 10 May 2014

New YouTube Video on UEFI support and .imgPTN files now available

I have made a new YouTube video http://www.youtube.com/watch?v=-Oo291vzfv0

I sound a bit 'nasal' due to hay-fever as usual!

E2B v1.38 is just being uploaded now.
No need to update if you are happy with your E2B drive. A few small changes were made, mainly in MyE2B.cfg support for moving the top menu heading down from the first line at the top, to any line (e.g. line 2,3 or 4) and also an option to adjust the offset that is automatically applied to the heading and bottom help text. Some new demo 'themes' have also been added - 'Mac' and 'StripedFlat_1024_pwd_is_fred' which has a master password and is in 1024x768 resolution (thanks Craig!) - see the Gallery here.

If you want to update your E2B drive, just extract the non-DPMS version to your existing E2B drive.


Wednesday 7 May 2014

Boot from a Zorin ISO with persistence (Easy2Boot)

Zorin is a good free linux substitute for Windows XP. It feels pretty-much like XP and includes WINE so it can run Windows applications. It seems to have quite a few drivers too (my audio, WiFi, trackpad and video just worked on my Acer 7741 laptop). If you just copy the ISO to your Easy2Boot USB drive it should just work as a 'Live CD' (but it won't boot from a VM - only from a real system as it looks for a real USB drive).

It would be handy to have persistence too. I did this by adding a .mnu file to Easy2Boot and a casper-rw file for persistence.

Persistence seemed to work and Zorin remembered changes to the Desktop, the wireless WPA password and keyboard/country settings. However there were some problems running Windows applications under WINE as there was insufficient temporary file space. I suspect that it was using the ramdrive instead of the persistence file system.

However, you can at least boot to Zorin and use the Chrome browser and play YouTube videos, etc. with the Desktop and country settings, etc. of your choice, without needing to install it.

Note: For Zorin 9 use the Zorin-os-9.1-core-64-persistent.mnu file in 2016 versions of  E2B,

Here are the instructions:

1. Download and copy a Zorin ISO (I used v8.1) to a suitable folder on your E2B drive (must be at 3rd level or deeper) - I used \_ISO\MAINMENU\MNU. Alternatively, the \_ISO\LINUX\MNU folder would also be OK. The 32-bit version would be a better choice if you want it to boot on a wider variety of systems.

2. Use RMPrepUSB to create a file formatted as an ext2 filesystem using the Create ext2 FS button.
    Filename        = zorin32-rw  (or zorin64-rw depending on which ISO you have)
    Volume name = casper-rw
    Size               =   (up to you! - I used 300MB)

3. Copy the appropriate E2B .mnu file (32 or 64-bit version) to the same folder as the .ISO file (see below). The Zorin .mnu files can befound in the \_ISO\docs\Sample mnu files\linus folder.

4. Run RMPrepUSB - Ctrl+F2   (WinContig) to ensure all files are contiguous.

That's it. Now boot it on a real system to try it out.

Instructions are also inside each .mnu file.

You can add many more linux ISOs with persistence in the same manner (even if they all use casper-rw as the persistent file system!). See the \_ISO\docs\Sample mnu files folder for more .mnu files.
This scheme works on both FAT32 and NTFS E2B USB drives (even if the version of linux you are booting to, cannot mount NTFS drives whilst booting).

Monday 5 May 2014

There are still weird BIOSes about!

I had two issues reported this week concerning booting .imgPTN images from E2B USB drives. Both issues show that even in the last few years, we still have BIOSes which have non-standard boot behaviour!

1. Intel Desktop Mainboard DP67BG

Art found that .imgPTN FAT32 image would not boot on this one mainboard but would boot OK on all other systems he had. It turned out that the partition geometry had to be set to 255 tracks per cylinder and 63 sectors per head instead of 128x63. I have now (v0.027) changed the default in MakePartImage to use 255x63.

2. Lenovo Thinkpad Edge E525 laptop

Alexandre found that on this laptop, it would not even try to boot from a .imgPTN FAT32 image but would boot OK from the same image via UEFI and boot to the E2B partition OK. It turned out that the .imgPTN FAT32 partition needed to be flagged as 'Active' (bootable) otherwise the BIOS would not try to boot from the USB drive in MBR\CSM mode! This was easily done by renaming all his .imgPTN files to .imgPTNA and now they all boot fine.

I am reluctant to always set the partition as Active as it may prevent some UEFI systems from booting (they may not like an 'Active' FAT32 partition and may only boot from it in EUFI mode).

The UEFI specification clearly states that the Boot Flag field '...shall not be used by UEFI firmware'. This does not appear to be the case for the Lenovo UEFI firmware!

If you see any similar behaviour, please let me know.

Friday 2 May 2014

MenuetOS - a tiny GUI OS!

I found MenuetOS today. An entire GUI OS that can be contained on a single 1.44MB floppy disk!
It is written in x86 assembler and there is a 32-bit and 64-bit version. A new version was released yesterday.

Add it to Easy2Boot and try it out for a bit of fun!

1. Download the floppy image file M64-0.99.58.ZIP  - or the 32-bit version
2. Unzip it to obtain .img file - e.g. M6409958.IMG
3. Copy the file to your E2B drive - e.g. to the \_ISO\MAINMENU folder
4. Try it!

Test using a Real system or QEMU. If you use VirtualBox, I found I needed to set a SB16 Sound  adapter in the Virtual Machine or disable it, and also disable VTx CPU acceleration and set a 32-bit OS. You may need to tweak a few settings to get it to run in VBox.


A more recent version of MenuetOS is Kolibri. The .img file still is only 1.44MB but it has network support, a basic text-only internet browser (WebView) and many games.

WebView showing a page from easy2boot.com

The forum is here, downloads here (.iso or .img works). To run under a VBox VM, I used - linux 32-bit, Sound Blaster 16, IDE, VTx OFF. This boots in just a few seconds!

___________________


I also tried adding the MRI GeekSquad ISO as a .imgPTN image file today and updated my previous blog on it here.



Thursday 1 May 2014

E2B v1.37 now available


  • New image partition extensions (see below)
  • Make_E2B_USB_Drive.cmd now installs grub4dos to the PBR and MBR
As well as .imgPTN, the following file extensions are now recognised:

.imgPTNA - same as .imgPTN but the partition is made Active (flagged as bootable). This may be required for some WindowsToGo first boot-time images to avoid a 'Windows could not complete' error on first boot. E2B v1.36 and later.
.imgPTNlba - same as .imgPTN but modifies the partition table - use this instead of .imgPTN is some BIOSes won't boot .imgPTN images. v1.37+
.imgPTNlbaA - same as .imgPTNlba but makes the first partition Active.
.imgPTNAlba23 - same as .imgPTNlba but partition entries 2 and 3 are not removed and partition 1 is made Active. This allows you to boot from a Windows image file but still be able to access the 2nd and 3rd partition on the E2B USB Hard disk. This extension cannot be used for UEFI booting. v1.37+
.imgPTNA23 - same as .imgPTNA but does not clear partition entries 2 and 3 - use for WinPE/WinToGo images on E2B USB hard disks where you want access to the 2nd and 3rd partitions when you boot from the image. Not for UEFI booting.  v1.37+

If you have an E2B USB hard drive which has 2 or 3 partitions, when you boot to a WinToGo image using a .imgPTN file, the 2nd and 3rd partitions on the E2B drive will be removed. You therefore cannot access any files on them when you boot to WinToGo. By using a .imgPTNA23 or .imgPTNAlba23 file extension, you can still access the 2nd and 3rd partitions on your E2B USB HDD.
Note that this is only for non-UEFI booting (UEFI booting requires the first partition to be a FAT32 partition).

The best booting compatibility is obtained using standard MBR boot code and a grub4dos PBR, however for Partition Image booting, a grub4dos MBR is required.  Make_E2B_USB_Drive.cmd now installs grub4dos to the PBR and MBR.