Differences between revisions 12 and 13
Revision 12 as of 2019-11-13 06:08:07
Size: 6363
Editor: ?JochenSprickerhof
Revision 13 as of 2021-04-21 07:05:01
Size: 6397
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from EFIStub

Translation(s): none

Since Wheezy, Debian kernel on x86 contain their own BootLoader called EFI stub. Therefore it is possible to load the kernel directly, without any additional bootloader (like grub-efi).


Copy the files

The UEFI firmware is only able to load files from the EFI partition (usually FAT). If you use a standard UEFI installation of Debian, you should copy the kernel and the initrd to /boot/efi. The best way to keep it up to date is to place a script in /etc/kernel/postinst.d/zz-update-efistub:

   1 #!/bin/sh
   2 cp /vmlinuz /boot/efi/EFI/debian/

Make it executable and launch it manually:

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

/etc/initramfs/post-update.d/zz-update-efistub (create the directory if it does not exist):

   1 #!/bin/sh
   2 cp /initrd.img /boot/efi/EFI/debian/

Make it executable and launch it manually:

chmod +x /etc/initramfs/post-update.d/zz-update-efistub

Add the boot entry

Replace /dev/sda3 with the device of your / partition, see the efibootmgr manpage if you EFI partition is not /dev/sda1:

export UUID=$(blkid -s UUID -o value /dev/sda3)
efibootmgr -c -g -L "Debian (EFI stub)" -l '\EFI\debian\vmlinuz' -u "root=UUID=$UUID ro quiet rootfstype=ext4 add_efi_memmap initrd=\\EFI\\debian\\initrd.img"

You may have to add --disk /dev/nvme0n1 in case it's not auto detected (nvme0n1 being the disk with the EFI partition).

You can check your new boot entry. Since EFI uses UCS2, it should look like this:

#efibootmgr -v

Or add the boot entry with a script

  1. Create the script below with it's contents. (Tip: Highlight and copy with linenumbers hidden)

  2. Edit the parts to accommodate your needs.
  3. Make it executable.
    • chmod a+x /sbin/create_EFI_Boot_Entry.sh

  4. Execute the script as root.

    • sudo create_EFI_Boot_Entry.sh

  5. (./) -- TriMoon 2018-04-24 19:12:01 B) {OK}

Here are some line numbers with usage explanation:

  • #13 The label you will see in the EFI boot menu.

  • #14 The kernel image to use by the UEFI-BIOS. (must be inside the EFI partition)

  • #15 The initrd image to use by the UEFI-BIOS. (must be inside the EFI partition)

  • #17-20 Compose default kernel parameters.

    • #18 Sets the file system partition for '/' to use by the kernel. (Automatically found from running system)

    • #19 Sets the file system type of '/' for use by the kernel. (Automatically found from running system)

    • #20 Sets the initrd image for use by the kernel. (from value at #15)

  • #24 Grabs the default kernel parameters in use inside Grub2's config file. (Automatically found from running system)

  • #27-38 Combine default and extra kernel parameters.

    • #28-30 Used when Grub2 config is detected (Combines values from #18-20 with #24)

    • #32-37 Used when there is NO Grub2 config detected. (Combines values from #18-20 with Manual extra kernel parameters)

      • #34-37 Manual extra kernel parameters that you can set that will be appended to the defaults from #18-20.

   1 #!/usr/bin/env bash
   2 #       /sbin/create_EFI_Boot_Entry.sh v0.2
   3 #       Automatically create an EFI Boot entry.
   4 #
   5 #       (C) 2018+ ©TriMoon™ <https://github.com/TriMoon>
   6 #       ------------------------------------------------
   7 #       License: BY-SA 4.0
   8 #       This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
   9 #       https://creativecommons.org/licenses/by-sa/4.0/
  10 #
  12 # First compose the variables used as arguments:
  13 label='Debian (EFI stub)'
  14 loader='\EFI\debian\vmlinuz' # Use single \'s !
  15 initrd='\EFI\debian\initrd.img' # Use single \'s !
  16 # Compose default kernel arguments for an EFI-boot
  17 printf -v largs "%s " \
  18         "root=UUID=$(findmnt -kno UUID /) ro" \
  19         "rootfstype=$(findmnt -kno FSTYPE /)" \
  20         "initrd=${initrd}"
  21 # Grab extra kernel arguments from grub2 config.
  22 grub_cmdline=''
  23 if test -f /etc/default/grub; then
  24         grub_cmdline="$(sed -nE '/^GRUB_CMDLINE_LINUX_DEFAULT=\"/ {s#GRUB_CMDLINE_LINUX_DEFAULT=\"##; s#\"$##; p}' </etc/default/grub)"
  25 fi
  26 # Append extra kernel arguments
  27 if test -n "${grub_cmdline}"; then
  28         printf -v largs "%s " \
  29                 "${largs%* }" \
  30                 "${grub_cmdline}"
  31 else
  32         printf -v largs "%s " \
  33                 "${largs%* }" \
  34                 "quiet splash" \
  35                 "add_efi_memmap" \
  36                 "intel_iommu=on" \
  37                 "nvidia-drm.modeset=1"
  38 fi
  39 # echo "${largs%* }"; exit
  40 # Then create the EFI entry:
  41 efibootmgr -c -L "${label}" -l "${loader}" -u "${largs%* }"

On my system this EFI-entry was created using the script above:

Boot0000* Debian (EFI stub)     HD(1,GPT,1e4d16a9-ba85-4a29-9fd1-277c77f4e461,0x800,0x100000)/File(\EFI\DEBIAN\VMLINUZ)r.o.o.t.=.U.U.I.D.=. .r.o. .r.o.o.t.f.s.t.y.p.e.=.e.x.t.4. .i.n.i.t.r.d.=.\.E.F.I.\.d.e.b.i.a.n.\.i.n.i.t.r.d...i.m.g. .q.u.i.e.t. .s.p.l.a.s.h. .i.n.t.e.l._.i.o.m.m.u.=.o.n. .n.v.i.d.i.a.-.d.r.m...m.o.d.e.s.e.t.=.1. .h.u.g.e.p.a.g.e.s.z.=.1.G.B. .h.u.g.e.p.a.g.e.s.=.4.

If you were installing Debian from UEFI medium, efibootmgr should be installed by default. However, sometimes it can report that EFI variables are not supported. If you are sure that you have EFI partition, probably you need to download efivar package and modprobe efivars module.