Ubuntu – Dual booting Ubuntu 12.04: UEFI and Legacy

dual-bootinstallationuefi

I'm trying to dual boot Ubuntu 12.04 (or 12.10) with Windows 8 on a new Sony Vaio, but have run into some problems 🙂

Specifically, my problems seem to come from choosing UEFI or Legacy as the Bootmode in the BIOS.

Here is what I have found so far:

  • Windows 8 needs to boot using UEFI, and doesn't work in Legacy mode
  • Ubuntu (both 12.04 and 12.10) needs to boot using Legacy, and won't boot (at least from the live disk) in UEFI mode

I have been able to boot Ubuntu using a live USB disc, provided that I change the Bootmode to Legacy. I haven't committed to installing it yet, because I don't really understand the consequences.

My main concerns are that instead of simply selecting Windows or Ubuntu in Grub, I would also have to change my Bootmode every single time, which seems like a lot more trouble than it should be.

So, the question: how can I install Ubuntu 12.04 or 12.10 in UEFI boot mode?

Best Answer

This is probably a Secure Boot issue, at least in part. (Selecting the correct EFI-mode boot option may be part of the issue, too.) On the one system I've got that can handle Secure Boot, enabling it and trying to boot from a disc that can boot in either EFI or BIOS mode, but without a valid Secure Boot signature, results in a BIOS-mode boot, even if I tell the computer to boot in EFI mode. This behavior exactly matches your description of what's happening to you. Furthermore, you say this is a new computer with Windows 8 installed, which means that it almost certainly shipped with Secure Boot active.

If I'm right, you have three options for how to proceed:

  • Disable Secure Boot in your firmware -- this is the easiest method if you're familiar with setting basic firmware options, but you'll need to track down the right one.
  • Install using a distribution that's been signed with a Secure Boot key -- Ubuntu 12.04's installer has not been so signed, AFAIK, but I suspect that Ubuntu 12.10's has been. I'm not positive of that, though. (I've not yet tested it on my Secure Boot-capable PC.) Fedora 18 is supposed to be signed, but it's not yet been released, and I'm not sure of the status of whatever pre-release version is out there.
  • Create your own Secure Boot keys, sign everything yourself, and use Secure Boot in that way. This is the hardest approach by far.

For more information on all of these approaches, see this Web page I wrote on the subject. Note that the Web page says nothing about OS installation. Most of the issues and procedures would be the same for OS installation as for anything else, but modifying files on an installation CD is trickier than modifying files on a USB flash drive, so keep that in mind when you're considering your options.


Addition: I can think of a number of reasons why you might be getting an "Operating system not found" message even when booting in EFI mode with Secure Boot disabled. I suggest you check the following:

  • Check your Secure Boot setting again. Yes, I know you said you've disabled it, but firmware settings can be tricky sometimes. It's worth double-checking.
  • Using gdisk or parted, verify that the USB drive you're using has a valid GUID Partition Table (GPT) with an EFI System Partition (ESP; identified as partition type code EF00 in gdisk, or by a "boot" flag in parted). If the disk uses an MBR partition table, a fussy firmware might reject it. Likewise if it lacks an ESP.
  • If the disk uses a hybrid optical disc/hard disk configuration (as some installation disk images do), it could be that a fussy firmware will reject it. In this case, backing it up, creating a fresh GPT on the disk with a new ESP, and restoring everything on a file-by-file basis might get it working.
  • Mount the ESP and look for a file called EFI/BOOT/bootx64.efi. (Case shouldn't matter; but see below.) This is the boot loader file. If it's absent, the disk won't boot. You'll need to figure out what happened to the file and restore it.
  • Although the FAT filesystem used on ESPs is case-insensitive, I've encountered one badly broken EFI with case sensitivity issues. Messing with the filename case might fix it, but there are a lot of possible variants.
  • Check that the ESP uses FAT32, not FAT16. Most EFIs seem to be happy with both, but the spec does say the ESP should be FAT32, and I know of one implementation that's unhappy with a FAT16 ESP.

You could also try booting something else in EFI mode. One possibility is rEFInd, which is an EFI boot loader that, if you can get it to boot, it may be able to detect and run the Ubuntu installer's boot loader. There's a CD image of rEFInd, but that really is a CD image, not a USB image. To create a USB image, you'd need to download the binary file and install it manually. Tip: There's a new install.sh script that's available here. (It's destined for the next release, but that release isn't finalized yet.) This version of the script includes a new option, --usedefault, that can be used to help create a bootable USB flash drive. You'd use it like this:

sudo ./install.sh --usedefault /dev/sdc1

This example should create an EFI-bootable USB flash drive on /dev/sdc1, provided that partition is an ESP on the USB flash drive. Note that you must partition the disk and create a FAT ESP before running install.sh.

One more possibility is to install in BIOS mode and then sort it out later. You can install rEFInd, gummiboot, or an EFI-enabled version of GRUB after installing in BIOS mode. You might need to jump through some hoops with renaming boot loaders to get things working, but if you can't get your installer to boot in EFI mode, this may be your only option.

Related Question