Earlier today, Jared blogged about a grub2 bug that can cause Ubuntu 12.04 to fail to boot on certain systems (including some of Dell’s 12G servers).  He talked about how to install Ubuntu with the system in BIOS mode, and then change it to UEFI mode after installing a newer version of grub2.

I’d like to mention an another way to get around this bug and install Ubuntu with the system in UEFI mode, as normal, by simply using the older, “legacy” GRUB on a USB key to boot into the Ubuntu installer.  Note that this method, too, is not officially supported.

To install Ubuntu Server 12.04 with this workaround, follow these steps:

  • Download the free, publicly available CentOS 6.3, x86_64, “minimal” .iso image.  (This CD image contains the “legacy” GRUB bootloader that we’ll use to boot Ubuntu.)
  • Acquire a USB flash drive with a FAT filesystem (or containing a partition with a FAT filesystem).  Many USB flash drives come with an already-formatted FAT filesystem--otherwise use “parted” or “fdisk” and “mkfs.vfat” tools in linux to create a partition and format it with a FAT filesystem.
  • On the USB flash drive, create a directory /EFI/BOOT.
  • Mount the CentOS image (“mount –oloop CentOS-6.3-x86_64-minimal.iso /mnt”, for example), and copy the files below from the CentOS image to the /EFI/BOOT directory on the USB flash drive.
    • EFI/BOOT/BOOTX64.efi
    • EFI/BOOT/BOOTX64.conf
    • EFI/BOOT/splash.xpm.gz
  • Mount the Ubuntu 12.04 Server CD, and copy the files below from the Ubuntu disk to the /EFI/BOOT directory on the USB flash drive:
    • install/vmlinuz
    • install/initrd.gz
  • Download the five new grub2-2.00 packages listed below, and put them on your USB flash drive.  At the time of this writing, these are available from Ubuntu Core developer Colin Watson's PPA (http://ppa.launchpad.net/cjwatson/grub/ubuntu/pool/main/g/grub2/).  You’ll want the latest version for the version of Ubuntu you are using—for example, grub-common_2.00-2ubuntu1~ppa2~precise_amd64.deb.
    • grub-common
    • grub2-common
    • grub-efi
    • grub-efi-amd64
    • grub-efi-amd64-bin
  • Next, edit the file EFI/BOOT/BOOTX64.conf on the USB flash drive.  Remove all of the lines below the word “hiddenmenu”, and add the following three lines to the end of the file:

    title Ubuntu 12.04

                kernel /EFI/BOOT/vmlinuz

                initrd /EFI/BOOT/initrd.gz

  • Put the USB flash drive and the Ubuntu CD into the system on which you want to install Ubuntu, and boot to the USB flash drive (hit “F11” during boot on Dell’s 12G servers to get the UEFI boot menu).  The USB flash drive will boot up, and you can install in UEFI mode as normal from the CD.
  • IMPORTANT:  After Ubuntu has been installed, but before the system is rebooted, follow these steps to install the working version of grub2 on your newly-installed system.  (A good point to do this on Ubuntu Server is when it pops up the “Finish the installation” window and asks if your clock is set to UTC.)
    • Go to virtual terminal 2 (hit alt-F2), and chroot into the installed system (“chroot /target”).
    • Mount your USB flash drive (or it’s FAT partition).
    • Install the new grub 2.00 packages that you copied to your USB flash drive earlier (“dpkg -i --force-breaks /mnt/grub2.00/grub*deb”, for example).
    • Type “exit”, then switch back to the install screen, with alt-F1.

Note that the same instructions should work with Ubuntu Desktop 12.04, except that the files to be copied from the Ubuntu desktop CD are /casper/vmlinuz and /casper/initrd.lz (instead of /install/vmlinuz and /install/initrd.gz), and the three lines added to the BOOTX64.conf file should look like this (the kernel parameters were just copied from the “Install Ubuntu” boot entry in the file boot/grub/grub.cfg on the Ubuntu CD):

title Ubuntu 12.04

kernel   /EFI/BOOT/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity quiet splash

initrd /EFI/BOOT/initrd.lz