Sunday, 24 April 2016

Boot Ubuntu 32-bit via UEFI from Easy2Boot

The current Ubuntu 32-bit 'LiveCD' Desktop ISO does not include the 32-bit grub2 UEFI boot files, but you can use the procedure below to add the required boot files to allow you to UEFI-boot..

The procedure below can be applied to other 32-bit linux ISOs that use grub2, as long as a \boot\grub\loopback.cfg file is present (or you can add the relevant entries).


Procedure

If you want to UEFI boot ubuntu-16.04-desktop-i386.iso, then:

1. First drag-and-drop the ISO onto the MPI Tool Kit MPI_FAT32 Windows Desktop icon and press ENTER when prompted for the size.

2. Now copy the .imgPTN file to your E2B drive (e.g. \_ISO\LINUX folder) and run the \MAKE_THIS_DRIVE_CONTIGUOUS.cmd script as usual.

3. Switch to the .imgPTN file. You can run \_ISO\SWITCH_E2B.exe and double-click on the .imgPTN file to do this. The E2B drive will now contain the Ubuntu partition.

Note: Check there is no \_ISO folder now and that the drive contents have changed. If not, unplug the E2B drive and reconnect it.

4. Download this zip file and extract the contents to the root of the E2B partition.

Note: The file is called grub_efi_32-bit_Ubuntu.zip and can be found in the Alternate Download Areas - Other Files.

5. In the \boot\grub folder you will see the original Ubuntu loopback.cfg file and a grub_example.cfg.

We need to make a new grub.cfg file. Use the grub_example.cfg as a template and replace the  'menuentry' lines with the 'menuentry' lines from the loopback.cfg file.

If you are using ubuntu-16.04-desktop-i386.iso, then all you need do is copy the grub_example.cfg to grub.cfg because it already contains the correct menuentry lines.

Note: I use 1024x768 because all UEFI systems have to support this graphics mode resolution.

grub_example.cfg:

if loadfont $prefix/font.pf2 ; then
  set gfxmode=1024x768
  insmod efi_gop
  insmod efi_uga
  insmod video_bochs
  insmod video_cirrus
  insmod gfxterm
  insmod png
  terminal_output gfxterm
fi

  set menu_color_normal=cyan/blue
  set menu_color_highlight=white/blue


menuentry "Try Ubuntu without installing" {
linux /casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper iso-scan/filename=${iso_path} quiet splash ---
initrd /casper/initrd.lz
}
menuentry "Install Ubuntu" {
linux /casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity iso-scan/filename=${iso_path} quiet splash ---
initrd /casper/initrd.lz
}
menuentry "Check disc for defects" {
linux /casper/vmlinuz  boot=casper integrity-check iso-scan/filename=${iso_path} quiet splash ---
initrd /casper/initrd.lz
}
menuentry "Test memory" {
linux16 /install/mt86plus
}

The lines in blue should always be present in your grub.cfg file. The lines in green should be pasted in from the original loopback.cfg file (or an existing grub.cfg file from somewhere in the original contents).

You should see a menu similar to this when you UEFI-boot


Make sure you now have present (as well as other files\folders):

  • \EFI\boot\bootia32.efi
  • \boot\grub\grub.cfg
  • \boot\grub\font.pf2
  • \boot\grub\i386-efi folder containing quite a few files (mostly .mod files)

Your E2B drive should now boot on a 32-bit UEFI system.

You can also MBR-boot from the CSM menu by choosing the second 'Alternate Boot' menu option.

If you want to add persistence, follow my previous blog here.

Postscript

Instead of merging the loopback.cfg text into a grub.cfg file, you can use the grub.cfg menu below to automatically load the loopback.cfg file contents:

\boot\grub\grub.cfg
if loadfont $prefix/font.pf2 ; then
  set gfxmode=1024x768
  insmod efi_gop
  insmod efi_uga
  insmod video_bochs
  insmod video_cirrus
  insmod gfxterm
  terminal_output gfxterm
fi

search.fs_label grub root

if [ -e /boot/grub/loopback.cfg ]; then

    set prefix=($root)/boot/grub
    configfile /boot/grub/loopback.cfg
fi

This may not work for all loopback.cfg files however, or may report an error or two depending on what is in the loopback.cfg file.

Tip: If you need to get the uuid of the USB partition, the CSM menu will list it in the heading, or use

probe -u $root --set=rootuuid

and then use $rootuuid where you need to insert the actual UUID.

e.g.
linux /vmlinuz boot=casper live-media=/dev/disk/by-uuid/$rootuuid quiet splash --