
For those interested, here is a way to install Debian and boot it with UEFI
if you have an UEFI motherboard.
Using UEFI with Debian requires expert knowledge so if you do not feel up to
it, keep your BIOS system.
1 Background
UEFI is a specification for motherboard's firmwares which is replacing the old
BIOS. For now, UEFI motherboards still include a BIOS compatibility layer.
The UEFI boot process is quite different from the BIOS one. It involves one
specific piece of the motherboard's firmware, the UEFI Boot Manager, which is
able to load boot loaders from FAT file systems on specially-typed partitions.
It can offer a boot menu (boot: Debian from HDD, Windows from HDD, USB stick,
DVD?), which can be configured
from a running operating system.
So, basically, to boot a system with UEFI, you need two things:
- to install an UEFI boot loader on a FAT-formated EFI System
Partition;
- to tell the UEFI Boot Manager to create an entry for that boot
loader.
2 Installation or preparation
If you are installing a new Debian system, read the first part. If you
already have a BIOS-bootable Debian system installed, read the second one.
In both cases you will have to use Debian testing, because stable's GRUB has
problems with UEFI. You can also use Debian stable while taking only GRUB from
testing though.
2.1 Installation of a new Debian system
There is no installer image for UEFI, so you can either:
- make your own, by installing an UEFI boot loader to an USB stick, which
will load a regular installer kernel and initrd;
- use a regular BIOS installer image, using the compatibility mode of your
motherboard.
The installer does not provide a convenient way to install an UEFI boot
loader, so you are going to install a regular BIOS boot loader at first, and
switch to UEFI later.
Use the expert mode and format your hard drive with a GUID Partition Table
(GPT). Create a small partition (1 MiB would be far enough), type it as a BIOS
Boot Partition (this is the untitled flag above the bootable one in Partman),
do not format it and do not mount it: this will be needed for BIOS booting.
Create another small partition (same kind of size), type it as an EFI System
Partition (this is the bootable flag), format it as FAT and mount it on
/boot/efi: this will be needed for UEFI booting.
Finish the installation as usual, installing GRUB for BIOS, and boot your new
system.
2.2 Preparation of an existing Debian system for UEFI
You need to use a GUID Partition Table on your hard drive. If you used an
MBR, you lost; you may try to convert it to GPT using a tool such as
gdisk, but that means operating
without a net, loosing your current boot loader in the process.
If there is no space left on your hard drive, use
Debian Live to make some. Create a small
partition (1 MiB would be far enough), type it as an EFI System Partition, format
it as FAT and mount it (permanently, using the
fstab)
on
/boot/efi (that directory will not exist, so create
it first).
3 Switch to GRUB UEFI
Install the package
grub-efi-amd64. Prepare it by
running the command (assuming your hard drive is
/dev/sda):
# grub-install /dev/sda
That will do three things:
- generate a GRUB image;
- install it to the EFI partition at efi/debian/grubx64.efi;
- try to configure the UEFI Boot Manager (the motherboard's boot
menu) to load it on start-up
That last step will fail. This is expected, because the UEFI Boot Manager can
only be configured from an operating system that was started from UEFI. So if
you stop here, you get an unbootable system.
Now, copy (a symlink would be relevant here, but that cannot be done on a FAT
file system!) the GRUB image to that other path on the EFI System Partition:
efi/boot/bootx64.efi. This is where the UEFI firmware
looks for a boot loader when it has not been configured for a specific path,
typically on removable media. Reboot to check that
If that trick worked, you are now on UEFI-booted system. Run
grub-install again, which should now succeed to configure the UEFI
Boot Manager. Reboot to check that you get a debian entry on the motherboard's
boot menu, and remove
efi/boot/bootx64.efi which is
no longer needed.