Start a Ubuntu Linux (14.04) Live CD in UEFI mode. In case of a USB boot device, disable "Fast Boot" in UEFI.
Open a terminal window (Ctrl+Alt+T)
To verify that you are actually running in UEFI mode, use this bash command:
$ [ -d /sys/firmware/efi ] && echo UEFI || echo BIOS
The resulting output should be:
UEFI
In case it says BIOS
, reboot into your firmware and correct the boot device preference.
To do the BIOS to EFI/UEFI conversion enter these commands:
$ sudo mount /dev/sda1 /mnt
$ sudo mkdir -p /mnt/boot/efi
$ sudo mount /dev/sda3 /mnt/boot/efi
$ sudo mount --bind /dev /mnt/dev
$ sudo mount --bind /proc /mnt/proc
$ sudo mount --bind /sys /mnt/sys
$ sudo mount --bind /run /mnt/run
$ modprobe efivars
$ sudo chroot /mnt
# apt-get install grub-efi-amd64
Apt-get networking failure?
# rm /etc/resolv.conf
# ln -s ../run/systemd/resolve/stub-resolv.conf resolv.conf
# apt-get install grub-efi-amd64
No apt-get failure
The following extra packages will be installed:
efibootmgr grub-efi-amd64-bin
The following packages will be removed:
grub-gfxpayload-lists grub-pc
...
After this operation, 2,399 kB of additional disk space will be used.
# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy --debug
Despite ending in error message:
Fatal: Couldn't open either sysfs or procfs directories for accessing EFI variables.
Try 'modprobe efivars' as root.
the next reboot already shows "ubuntu" in the firmware its boot options menu, and boots to the console as before, except for now booting in efi mode:
$ dmesg | grep EFI
efi: EFI v2.31 by American Megatrends
fb0: EFI VGA frame buffer device
EFI Variables Facility v0.08 2004-May-17
fb: switching to inteldrmfb from EFI VGA
In case something goes wrong, https://superuser.com/questions/376470/how-to-reinstall-grub2-efi might help.
Broadly speaking, you need to install an EFI-mode boot loader for Linux on the USB drive you've prepared. This boot loader should be stored as EFI/BOOT/bootx64.efi
on the EFI System Partition (ESP), which is a FAT partition on the disk. There's a chance that the disk you've prepared lacks an ESP, so you may need to create it. (Even an ordinary FAT partition is usually sufficient, so if the disk has a FAT partition, you might not need a separate ESP.)
The tricky thing about this is that the boot loader you write to the disk must be properly configured to boot the installation on the disk. GRUB taken from the Ubuntu installation .iso
file won't work without changes, because it's configured to boot the Ubuntu installer, not the installation you've created on the USB drive. Thus, you must know enough about the boot loader to know how to configure it, and enough about your installation to know what values to put in the boot loader's configuration file.
Unfortunately, GRUB 2 is a very difficult boot loader to configure; its configuration file format is rather complex, and is usually created by specialized scripts. Even the binary may need to be modified for your specific situation, since the main configuration file (grub.cfg
) is normally located on the Ubuntu root (/
) or /boot
partition, meaning that the binary must be modified for your particular installation.
I've written a page on EFI boot loaders for Linux that covers many alternatives, most of which are easier to configure than GRUB 2. My own rEFInd is likely to be the easiest to set up and configure, since it tries to auto-detect Linux kernels when it starts, and it can usually figure out what options to pass to the kernel to get the system booted. Thus, configuration file changes needed to boot with rEFInd are minimal, and sometimes non-existent.
One big caveat in this is Secure Boot. If you want the computer to boot with Secure Boot active, you must provide either Shim (shimx64.efi
) or PreLoader (preloader.efi
) as the boot loader (renamed to EFI/BOOT/bootx64.efi
), with your follow-on boot loader renamed appropriately for Shim or PreLoader. Furthermore, depending on the boot loader in question, you might need to add keys or hashes to the firmware whenever you boot your disk on a new computer. In this case, it's probably worth going to the hassle of using GRUB 2 on the new computer, since Ubuntu provides all the pieces necessary to get a computer to boot Ubuntu without messing with keys or hashes.
Best Answer
xorriso turned out to be a bad guess. My guess which seemed to work was to install using EFI. Installing in legacy boot mode for the install USB resulted in an HD without an EFIboot partition. The problem was, I could only see my custom install menu when booting from legacy mode.
So, I needed a way to do an EFI install using my preseed file. I looked through the grub files on the USB installer and compared them to the GRUB menu I was seeing in EFI boot, and found that the boot/grub/grub.cfg file matched. So I added the following entry:
This got everything working.