Boot Debian system with EFI Stub kernel

31 08 2016

I try to explain the process of install a Debian system with UEFI and use the EFI Stub property for load the kernel and the ram disk directly from the EFI system firmware, leaving aside “grub-efi” and scratching some seconds at boot time.

– Be sure that UEFI is enabled in your system booting firmware.

– Install Debian following the normal way until the partitioning step.

– UEFI require the following partitioning points:

* Around "500MB" of space
* Bootable flag on
* Partition type "EFI System Partition"

You can select automatic partitioning, and the Debian Installation process will create it automatically or doing the partitioning by hand using the indicated values.

Don’t create this partition under software RAID or LVM, the UEFI won’t read the files under that.

– End with the installation and reboot. If it went correctly, you have a polish running system, booted with grub-uefi, with the UEFI partition mounted under /boot/efi:

/dev/sda1 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)

– Now is time to change the boot process into a EFI Stub, copy the kernel and the ram disk into the UEFI partition:

# cp /vmlinuz /initrd.img /boot/efi/EFI/debian/

– Look for your root filesystem UUID (in this example is sda2, the place were the linux is installed):

# blkid /dev/sda2
/dev/sda2: UUID="955548bd-9c77-4893-8633-3a5e7966dfc9" TYPE="ext4" PARTUUID="4cd59271-18a2-4d00-a65a-a106ee030a1a"

– And create an entry into the UEFI firmware for the linux EFIStub (replace the UUID number with your particular reference):

# efibootmgr -c -g -L "Debian (EFI stub)" -l '\EFI\debian\vmlinuz' -u "root=UUID=955548bd-9c77-4893-8633-3a5e7966dfc9 ro quiet rootfstype=ext4 add_efi_memmap initrd=\\EFI\\debian\\initrd.img"

– Check the UEFI information, the new entry is at the bottom:

# efibootmgr -v
BootCurrent: 0004
BootOrder: 0005,0004,0000,0001,0002,0003
Boot0000* EFI Virtual disk (0.0)
Boot0001* EFI VMware Virtual IDE CDROM Drive (IDE 1:0)
Boot0002* EFI Network
Boot0003* EFI Internal Shell (Unsupported option)
Boot0004* debian
Boot0005* Debian (EFI stub)
root@uefi:/boot/efi/EFI/debian# efibootmgr -v
BootCurrent: 0004
BootOrder: 0005,0004,0000,0001,0002,0003
Boot0000* EFI Virtual disk (0.0) ACPI(a0341d0,0)PCI(15,0)PCI(0,0)SCSI(0,0)
Boot0001* EFI VMware Virtual IDE CDROM Drive (IDE 1:0) ACPI(a0341d0,0)PCI(7,1)ATAPI(1,0,0)
Boot0002* EFI Network ACPI(a0341d0,0)PCI(16,0)PCI(0,0)MAC(MAC(005056948a0a,1)
Boot0003* EFI Internal Shell (Unsupported option) MM(b,e1a3000,e42ffff)FvFile(c57ad6b7-0515-40a8-9d21-551652854e37)
Boot0004* debian HD(1,800,ee000,4f3b579c-10cb-44ca-b845-475b2409eaf7)File(\EFI\debian\grubx64.efi)
Boot0005* Debian (EFI stub) HD(1,800,ee000,4f3b579c-10cb-44ca-b845-475b2409eaf7)File(\EFI\debian\vmlinuz)r.o.o.t.=.U.U.I.D.=. .r.o. .q.u.i.e.t. .r.o.o.t.f.s.t.y.p.e.=.e.x.t.4. .a.d.d._.e.f.i._.m.e.m.m.a.p. .i.n.i.t.r.d.=.\.E.F.I.\.d.e.b.i.a.n.\.i.n.i.t.r.d...i.m.g.
Boot0007* Debian HD(1,800,ee000,4f3b579c-10cb-44ca-b845-475b2409eaf7)File(\EFI\debian\grubx64.efi

– Look close to the information reported, the BootOrder have the new entry listed first, in the next boot the system will take it:

BootCurrent: 0004
BootOrder: 0005,0004,0000,0001,0002,0003

– Now, reboot and check the BootCurrent again:

BootCurrent: 0005
BootOrder: 0005,0004,0000,0001,0002,0003

– Basically it’s done. But for update the kernel and the ram disk automatically when an upgraded is installed, or removed, create the following files and make them executable:

# cat > /etc/kernel/postinst.d/zz-update-efistub << EOF
echo "Updating EFI boot files..."
cp /vmlinuz /initrd.img /boot/efi/EFI/debian/

# chmod +x /etc/kernel/postinst.d/zz-update-efistub# cp /etc/kernel/postinst.d/zz-update-efistub /etc/kernel/postrm.d/zz-update-efistub

As a note, is it possible to substitute this script with systemd units. Look into the Arch linux wiki for more info.

– Thats all.



— But if you have some problems:

– If you need to revert the chage, for example, to keep boot0004 first again, execute:

# efibootmgr -o 0004,0005,0000,0001,0002,0003

– If you lost the Debian entry created at installation time, recrete it with this:

# efibootmgr -c -g -L "Debian" -l '\EFI\debian\grubx64.efi'

– If you have problems with EFI variables, be sure that you have installed “efivar” and “efivars” kernel module loaded (modproble efivars).


More info:




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: