Differences between revisions 8 and 9
Revision 8 as of 2017-05-07 13:43:14
Size: 2317
Editor: ?JochenSprickerhof
Comment:
Revision 9 as of 2018-04-24 15:51:15
Size: 4501
Editor: TriMoon
Comment: Added new section with an automation script
Deletions are marked like this. Additions are marked like this.
Line 38: Line 38:
Line 43: Line 44:
}}}

=== Or add the boot entry with a script ===
 1. Create the script below with it's contents. ~-'''''(Tip: Highlight and copy with linenumbers hidden)'''''-~
 1. Edit the parts to accommodate your needs.
  * See the [[http://manpages.debian.net/cgi-bin/man.cgi?query=bash|bash]], [[http://manpages.debian.net/cgi-bin/man.cgi?query=findmnt|findmnt]] and [[http://manpages.debian.net/cgi-bin/man.cgi?query=efibootmgr|efibootmgr]] manpage's of the utilities used for/in this script.
 1. Make it executable.
  ~-''chmod a+x create_EFI_Boot_Entry.sh''-~
 1. Execute the script as '''root'''.
  ~-''sudo create_EFI_Boot_Entry.sh''-~
 * (./) -- TriMoon <<DateTime(2018-04-24T18:51:14+0300)>> B) {OK}

Here are some line numbers with explanation:
 * ~-#12-~ The label you will see in the EFI boot menu.
 * ~-#13-~ The kernel image to use by the UEFI-BIOS. ~-'''''(inside the EFI partition)'''''-~
 * ~-#14-~ The initrd image to use by the UEFI-BIOS. ~-'''''(inside the EFI partition)'''''-~
 * ~-#16-~ The '/' file system to use by the kernel. ~-'''''(Automatically found from running system)'''''-~
 * ~-#17-~ The file system type of '/'. ~-'''''(Automatically found from running system)'''''-~
 * ~-#18-~ Default kernel parameters.
 * ~-#19-21-~ Extra kernel parameters.
{{{#!highlight bash
#!/usr/bin/env bash
# create_EFI_Boot_Entry.sh v0.1 Automatically create an EFI Boot entry.
#
# (C) 2018+ ©TriMoon™ <https://github.com/TriMoon>
# ------------------------------------------------
# License: BY-SA 4.0
# This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
# https://creativecommons.org/licenses/by-sa/4.0/
#

# First compose the variables used as arguments:
label='Debian (EFI stub)'
loader='\EFI\debian\vmlinuz' # Use single \'s !
initrd='\EFI\debian\initrd.img' # Use single \'s !
printf -v largs "%s " \
 "root=UUID=$(findmnt -kno UUID /)" \
 "rootfstype=$(findmnt -kno FSTYPE /)" \
 "ro quiet splash" \
 "add_efi_memmap" \
 "intel_iommu=on" \
 "nvidia-drm.modeset=1" \
 "initrd=$initrd"

# Then create the EFI entry:
efibootmgr -c -L "${label}" -l "${loader}" -u "${largs%* }"

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/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
/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 can check your new boot entry. Since EFI uses UCS2, it should look like this:

#efibootmgr -v
...
.i.n.i.t.r.d.=.\.E.F.I.\.d.e.b.i.a.n.\.i.n.i.t.r.d.

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 create_EFI_Boot_Entry.sh

  4. Execute the script as root.

    • sudo create_EFI_Boot_Entry.sh

  5. (./) -- TriMoon 2018-04-24 15:51:14 B) {OK}

Here are some line numbers with explanation:

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

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

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

  • #16 The '/' file system to use by the kernel. (Automatically found from running system)

  • #17 The file system type of '/'. (Automatically found from running system)

  • #18 Default kernel parameters.

  • #19-21 Extra kernel parameters.

   1 #!/usr/bin/env bash
   2 #       create_EFI_Boot_Entry.sh v0.1 Automatically create an EFI Boot entry.
   3 #
   4 #       (C) 2018+ ©TriMoon™ <https://github.com/TriMoon>
   5 #       ------------------------------------------------
   6 #       License: BY-SA 4.0
   7 #       This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
   8 #       https://creativecommons.org/licenses/by-sa/4.0/
   9 #
  10 
  11 # First compose the variables used as arguments:
  12 label='Debian (EFI stub)'
  13 loader='\EFI\debian\vmlinuz' # Use single \'s !
  14 initrd='\EFI\debian\initrd.img' # Use single \'s !
  15 printf -v largs "%s " \
  16         "root=UUID=$(findmnt -kno UUID /)" \
  17         "rootfstype=$(findmnt -kno FSTYPE /)" \
  18         "ro quiet splash" \
  19         "add_efi_memmap" \
  20         "intel_iommu=on" \
  21         "nvidia-drm.modeset=1" \
  22         "initrd=$initrd"
  23 
  24 # Then create the EFI entry:
  25 efibootmgr -c -L "${label}" -l "${loader}" -u "${largs%* }"

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.


CategoryBootProcess