Note that the 'secure boot' option of UEFI is a different matter that only plays on computers on which Microsoft's Windows 8 or later is the principal OS.
The Preliminaries
The UEFI Boot Manager searches by default VFAT-formatted partitions for an /efi/boot/bootx64.efi boot loader and uses the first one that is found. It is customary to provide an EFI Systems Partition (ESP) on the HD specifically for that purpose. This partition should preferably be 200--500 MB in size, with room for other OS'es and boot loaders. If an existing ESP isn't large enough, then I recommend copying its contents to a memory stick and replacing that content after the HD has been (re)partitioned or resized.
HD resizing
UEFI can work both with the older MBR partition table and with the newer GUID Partition Table (GPT). In either case you need to find or make room for the ESP on the HD that you boot from. Use a recent version of the GParted or PartedMagic bootable CD to do this. Although any old partition with a FAT32 or FAT16 file system will do, there is now a separate format ('ef') for that purpose. It does not have to be the first partition on the drive, but it simplifies things if it is. I assume in the following that the ESP is /dev/sda1, with 'esp' and 'boot' flags set.
Note that there may already be a tiny 1MB BIOSGRUB partition on the HD when you use GPT, which will remain unused after the switch to UEFI booting.
Switching from BIOS to UEFI
With the ESP present and prepared, carry out the commands below with root privileges.
Configuring GRUB for UEFI
Mount the ESP (assumed to be /dev/sda1) on a newly-made mount point
Code: Select all
# mkdir /boot/efi
# mount /dev/sda1 /boot/efi
Code: Select all
# modprobe efivars
# aptitude install grub-efi-amd64
# grub-install /dev/sda
# update-grub
Configuring UEFI for GRUB
The above installation has installed the /EFI/debian/grubx64.efi boot loader on the ESP, which can be used provided that we let UEFI know of its existence. We can do this in two ways: simple, suited for Debian GNU/Linux as the only bootable OS; and not-so-simple, also suited when there are multiple boot options.
Since we are still in BIOS mode at this stage, we must do it first the simple way. The more complicated way can be implemented after rebooting in UEFI mode. For the simple way we need only copy and rename grubx64.efi as follows,
Code: Select all
# mkdir /boot/efi/EFI/boot
# cp /boot/efi/EFI/debian/grubx64.efi \
/boot/efi/EFI/boot/bootx64.efi
The computer may now be rebooted in UEFI mode, after first enabling UEFI booting in the computer setup menu.
More UEFI boot options
The UEFI Boot Manager looks at non-volatile RAM (NVRAM) on the motherboard for additional instructions, which may be provided or changed with efibootmgr, which also relies on kernel module efivars.
Instead of letting the UEFI Boot Manager look for a bootx64.efi boot loader in a default path, we can tell it specifically where our grubx64.efi is located with the commands
Code: Select all
# modprobe efivars
# efibootmgr -c \
-l "\\EFI\\debian\\grubx64.efi" \
-L "Debian GNU/Linux"
Code: Select all
# efibootmgr -o 3,4
The UEFI boot menu
Consult your computer manual on how to reach the UEFI boot menu at startup; on my VMware Fusion VM this needs hitting the fn-F2 key. Two items in the UEFI menu are of interest: Boot Manager and Boot Maintenance Manager.
Boot Manager
This menu item shows all bootloaders that are stored in NVRAM, such as our GRUB installed with efibootmgr. The desired bootloader can be chosen in this menu when it is not the default.
Boot Maintenance Manager
This menu item contains the option to Boot from a File, and gives a choice of available (VFAT-formatted) partitions. We can find the boot loader of our choosing by following the appropriate path. This way, our computer stays bootable in case something went wrong during the earlier switch-over.
The UEFI boot menu does the job, yet is rather stark-looking, while entering it requires a quick reaction during the initial startup. I'll discuss the nice-looking rEFInd boot manager in the follow-up to this post.
Enjoy!