§2023-10-26

UEFI is a hardware-based firmware, and GRUB is software that interacts with the firmware to initiate the booting of the operating system. Together, they work in tandem to start the computer and load the operating system.

GRUB 2 superseded GRUB legacy long ago, today it is commonly called simply "GRUB".

sdb                                                                             
|-sdb1 vfat     FAT32       47DB-2E54                                           
|-sdb2 swap     1           78672ca5-f865-4282-8cee-df35a385abd9                
`-sdb3 ext4     1.0         4a47f5a1-b321-4b88-8342-b6753403a93c   51.5G    12% /

emerge emerge sys-fs/dosfstools

  1. format efi partition(VFAT)
(chroot) h2Jammy /usr/src # mkfs.vfat -F 32 -n efi-boot /dev/sdb1 
mkfs.fat 4.2 (2021-01-31)
mkfs.fat: Warning: lowercase labels might not work properly on some systems
(chroot) h2Jammy /usr/src # mkdir /boot/efi
(chroot) h2Jammy /usr/src # mount /dev/sdb1 /boot/efi/   <-- ubuntu, gentoo ... convetion to be mounted here
(chroot) h2Jammy /usr/src # lsblk -f
sdb                                                                                
|-sdb1 vfat     FAT32 efi-boot 6B3D-DD28                               511M     0% /boot/efi
|-sdb2 swap     1              78672ca5-f865-4282-8cee-df35a385abd9                
`-sdb3 ext4     1.0            4a47f5a1-b321-4b88-8342-b6753403a93c   51.5G    12% /
#LABEL=/boot/efi
UUID=6B3D-DD28                                          /boot/efi       vfat            noauto,noatime          1 2
#LABEL=/root
UUID=4a47f5a1-b321-4b88-8342-b6753403a93c               /               ext4            defaults                0 1     
#LABEL=swap             none            swap            sw              0 0
UUID=78672ca5-f865-4282-8cee-df35a385abd9               none            swap            sw                      0 0
  1. install grub

(chroot) h2Jammy /usr/src # echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf
(chroot) h2Jammy /usr/src # emerge --ask --update --newuse --verbose sys-boot/grub   <-- safer with --newuse
(chroot) h2Jammy /usr/src # tree /boot/
/boot/               <-- start with an empty
└── efi

2 directories, 0 files
(chroot) h2Jammy /usr/src # grub-install --efi-directory=/boot/efi
Installing for x86_64-efi platform.
Installation finished. No error reported.
(chroot) h2Jammy /usr/src # tree /boot/
/boot/
├── efi
│   └── EFI
│       └── gentoo
│           └── grubx64.efi       <-- bootloader
└── grub
    ├── fonts
    │   └── unicode.pf2
    ├── grubenv                   <--  GRUB Environment Block
    ├── locale
    │   ├── ast.mo
    │   ├── ca.mo
    │   ├── da.mo
    │   ├── de_CH.mo
    │   ├── de@hebrew.mo
    │   ├── de.mo
    │   ├── en@arabic.mo
    │   ├── en@cyrillic.mo
    │   ├── en@greek.mo
    │   ├── en@hebrew.mo
    │   ├── en@piglatin.mo
    │   ├── en@quot.mo
    │   ├── eo.mo
    │   ├── es.mo
    │   ├── fi.mo
    │   ├── fr.mo
    │   ├── gl.mo
    │   ├── hr.mo
    │   ├── hu.mo
    │   ├── id.mo
    │   ├── it.mo
    │   ├── ja.mo
    │   ├── ko.mo
    │   ├── lg.mo
    │   ├── lt.mo
    │   ├── nb.mo
    │   ├── nl.mo
    │   ├── pa.mo
    │   ├── pl.mo
    │   ├── pt_BR.mo
    │   ├── pt.mo
    │   ├── ro.mo
    │   ├── ru.mo
    │   ├── sl.mo
    │   ├── sr.mo
    │   ├── sv.mo
    │   ├── tr.mo
    │   ├── uk.mo
    │   ├── vi.mo
    │   ├── zh_CN.mo
    │   └── zh_TW.mo
    ├── themes
    │   └── starfield
    │       ├── blob_w.png
    │       ├── boot_menu_c.png
    │       ├── boot_menu_e.png
    │       ├── boot_menu_ne.png
    │       ├── boot_menu_n.png
    │       ├── boot_menu_nw.png
    │       ├── boot_menu_se.png
    │       ├── boot_menu_s.png
    │       ├── boot_menu_sw.png
    │       ├── boot_menu_w.png
    │       ├── COPYING.CC-BY-SA-3.0
    │       ├── dejavu_10.pf2
    │       ├── dejavu_12.pf2
    │       ├── dejavu_14.pf2
    │       ├── dejavu_16.pf2
    │       ├── dejavu_bold_14.pf2
    │       ├── README
    │       ├── slider_c.png
    │       ├── slider_n.png
    │       ├── slider_s.png
    │       ├── starfield.png
    │       ├── terminal_box_c.png
    │       ├── terminal_box_e.png
    │       ├── terminal_box_ne.png
    │       ├── terminal_box_n.png
    │       ├── terminal_box_nw.png
    │       ├── terminal_box_se.png
    │       ├── terminal_box_s.png
    │       ├── terminal_box_sw.png
    │       ├── terminal_box_w.png
    │       └── theme.txt
    └── x86_64-efi
        ├── acpi.mod
        ├── adler32.mod
        ├── affs.mod
        ├── afs.mod
        ├── afsplitter.mod
        ├── ahci.mod
        ├── all_video.mod
        ├── aout.mod
        ├── appleldr.mod
        ├── archelp.mod
        ├── ata.mod
        ├── at_keyboard.mod
        ├── backtrace.mod
        ├── bfs.mod
        ├── bitmap.mod
        ├── bitmap_scale.mod
        ├── blocklist.mod
        ├── boot.mod
        ├── bsd.mod
        ├── bswap_test.mod
        ├── btrfs.mod
        ├── bufio.mod
        ├── cat.mod
        ├── cbfs.mod
        ├── cbls.mod
        ├── cbmemc.mod
        ├── cbtable.mod
        ├── cbtime.mod
        ├── chain.mod
        ├── cmdline_cat_test.mod
        ├── cmp.mod
        ├── cmp_test.mod
        ├── command.lst
        ├── configfile.mod
        ├── core.efi
        ├── cpio_be.mod
        ├── cpio.mod
        ├── cpuid.mod
        ├── crc64.mod
        ├── cryptodisk.mod
        ├── crypto.lst
        ├── crypto.mod
        ├── cs5536.mod
        ├── ctz_test.mod
        ├── datehook.mod
        ├── date.mod
        ├── datetime.mod
        ├── diskfilter.mod
        ├── disk.mod
        ├── div.mod
        ├── div_test.mod
        ├── dm_nv.mod
        ├── echo.mod
        ├── efifwsetup.mod
        ├── efi_gop.mod
        ├── efinet.mod
        ├── efi_uga.mod
        ├── ehci.mod
        ├── elf.mod
        ├── eval.mod
        ├── exfat.mod
        ├── exfctest.mod
        ├── ext2.mod
        ├── extcmd.mod
        ├── f2fs.mod
        ├── fat.mod
        ├── file.mod
        ├── fixvideo.mod
        ├── font.mod
        ├── fshelp.mod
        ├── fs.lst
        ├── functional_test.mod
        ├── gcry_arcfour.mod
        ├── gcry_blowfish.mod
        ├── gcry_camellia.mod
        ├── gcry_cast5.mod
        ├── gcry_crc.mod
        ├── gcry_des.mod
        ├── gcry_dsa.mod
        ├── gcry_idea.mod
        ├── gcry_md4.mod
        ├── gcry_md5.mod
        ├── gcry_rfc2268.mod
        ├── gcry_rijndael.mod
        ├── gcry_rmd160.mod
        ├── gcry_rsa.mod
        ├── gcry_seed.mod
        ├── gcry_serpent.mod
        ├── gcry_sha1.mod
        ├── gcry_sha256.mod
        ├── gcry_sha512.mod
        ├── gcry_tiger.mod
        ├── gcry_twofish.mod
        ├── gcry_whirlpool.mod
        ├── geli.mod
        ├── gettext.mod
        ├── gfxmenu.mod
        ├── gfxterm_background.mod
        ├── gfxterm_menu.mod
        ├── gfxterm.mod
        ├── gptsync.mod
        ├── grub.efi
        ├── gzio.mod
        ├── halt.mod
        ├── hashsum.mod
        ├── hdparm.mod
        ├── hello.mod
        ├── help.mod
        ├── hexdump.mod
        ├── hfs.mod
        ├── hfspluscomp.mod
        ├── hfsplus.mod
        ├── http.mod
        ├── iorw.mod
        ├── iso9660.mod
        ├── jfs.mod
        ├── jpeg.mod
        ├── json.mod
        ├── keylayouts.mod
        ├── keystatus.mod
        ├── ldm.mod
        ├── legacycfg.mod
        ├── legacy_password_test.mod
        ├── linux16.mod
        ├── linux.mod
        ├── loadbios.mod
        ├── loadenv.mod
        ├── loopback.mod
        ├── lsacpi.mod
        ├── lsefimmap.mod
        ├── lsefi.mod
        ├── lsefisystab.mod
        ├── lsmmap.mod
        ├── ls.mod
        ├── lspci.mod
        ├── lssal.mod
        ├── luks2.mod
        ├── luks.mod
        ├── lvm.mod
        ├── lzopio.mod
        ├── macbless.mod
        ├── macho.mod
        ├── mdraid09_be.mod
        ├── mdraid09.mod
        ├── mdraid1x.mod
        ├── memdisk.mod
        ├── memrw.mod
        ├── minicmd.mod
        ├── minix2_be.mod
        ├── minix2.mod
        ├── minix3_be.mod
        ├── minix3.mod
        ├── minix_be.mod
        ├── minix.mod
        ├── mmap.mod
        ├── moddep.lst
        ├── modinfo.sh
        ├── morse.mod
        ├── mpi.mod
        ├── msdospart.mod
        ├── mul_test.mod
        ├── multiboot2.mod
        ├── multiboot.mod
        ├── nativedisk.mod
        ├── net.mod
        ├── newc.mod
        ├── nilfs2.mod
        ├── normal.mod
        ├── ntfscomp.mod
        ├── ntfs.mod
        ├── odc.mod
        ├── offsetio.mod
        ├── ohci.mod
        ├── part_acorn.mod
        ├── part_amiga.mod
        ├── part_apple.mod
        ├── part_bsd.mod
        ├── part_dfly.mod
        ├── part_dvh.mod
        ├── part_gpt.mod
        ├── partmap.lst
        ├── part_msdos.mod
        ├── part_plan.mod
        ├── part_sun.mod
        ├── part_sunpc.mod
        ├── parttool.lst
        ├── parttool.mod
        ├── password.mod
        ├── password_pbkdf2.mod
        ├── pata.mod
        ├── pbkdf2.mod
        ├── pbkdf2_test.mod
        ├── pcidump.mod
        ├── pgp.mod
        ├── play.mod
        ├── png.mod
        ├── priority_queue.mod
        ├── probe.mod
        ├── procfs.mod
        ├── progress.mod
        ├── raid5rec.mod
        ├── raid6rec.mod
        ├── random.mod
        ├── rdmsr.mod
        ├── read.mod
        ├── reboot.mod
        ├── regexp.mod
        ├── reiserfs.mod
        ├── relocator.mod
        ├── romfs.mod
        ├── scsi.mod
        ├── search_fs_file.mod
        ├── search_fs_uuid.mod
        ├── search_label.mod
        ├── search.mod
        ├── serial.mod
        ├── setjmp.mod
        ├── setjmp_test.mod
        ├── setpci.mod
        ├── sfs.mod
        ├── shift_test.mod
        ├── signature_test.mod
        ├── sleep.mod
        ├── sleep_test.mod
        ├── smbios.mod
        ├── spkmodem.mod
        ├── squash4.mod
        ├── strtoull_test.mod
        ├── syslinuxcfg.mod
        ├── tar.mod
        ├── terminal.lst
        ├── terminal.mod
        ├── terminfo.mod
        ├── test_blockarg.mod
        ├── testload.mod
        ├── test.mod
        ├── testspeed.mod
        ├── tftp.mod
        ├── tga.mod
        ├── time.mod
        ├── tpm.mod
        ├── trig.mod
        ├── tr.mod
        ├── true.mod
        ├── udf.mod
        ├── ufs1_be.mod
        ├── ufs1.mod
        ├── ufs2.mod
        ├── uhci.mod
        ├── usb_keyboard.mod
        ├── usb.mod
        ├── usbms.mod
        ├── usbserial_common.mod
        ├── usbserial_ftdi.mod
        ├── usbserial_pl2303.mod
        ├── usbserial_usbdebug.mod
        ├── usbtest.mod
        ├── video_bochs.mod
        ├── video_cirrus.mod
        ├── video_colors.mod
        ├── video_fb.mod
        ├── videoinfo.mod
        ├── video.lst
        ├── video.mod
        ├── videotest_checksum.mod
        ├── videotest.mod
        ├── wrmsr.mod
        ├── xfs.mod
        ├── xnu.mod
        ├── xnu_uuid.mod
        ├── xnu_uuid_test.mod
        ├── xzio.mod
        ├── zfscrypt.mod
        ├── zfsinfo.mod
        ├── zfs.mod
        └── zstd.mod

10 directories, 351 files
(chroot) h2Jammy /usr/src # 
# GRUB Environment Block
# WARNING: Do not edit this file by tools other than grub-editenv!!!
##################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
  1. install kernel and initramfs
(chroot) h2Jammy /usr/src/linux-6.1.57-gentoo # make install INSTALL_PATH=/boot
  INSTALL /boot
dracut: Executing: /usr/bin/dracut -f --kernel-image arch/x86/boot/bzImage --no-uefi --kver 6.1.57-gentoo-x86_64 /tmp/kernel-install.staging.GsZUqMa/initrd
dracut: dracut module 'dash' will not be installed, because command 'dash' could not be found!
dracut: dracut module 'mksh' will not be installed, because command 'mksh' could not be found!
dracut: dracut module 'systemd-integritysetup' will not be installed, because command '/lib/systemd/systemd-integritysetup' could not be found!
dracut: dracut module 'systemd-integritysetup' will not be installed, because command '/lib/systemd/system-generators/systemd-integritysetup-generator' could not be found!
dracut: dracut module 'systemd-pcrphase' will not be installed, because command '/lib/systemd/systemd-pcrphase' could not be found!
dracut: dracut module 'systemd-veritysetup' will not be installed, because command '/lib/systemd/systemd-veritysetup' could not be found!
dracut: dracut module 'systemd-veritysetup' will not be installed, because command '/lib/systemd/system-generators/systemd-veritysetup-generator' could not be found!
dracut: dracut module 'modsign' will not be installed, because command 'keyctl' could not be found!
dracut: dracut module 'busybox' will not be installed, because command 'busybox' could not be found!
dracut: dracut module 'dbus-broker' will not be installed, because command 'dbus-broker' could not be found!
dracut: dracut module 'rngd' will not be installed, because command 'rngd' could not be found!
dracut: dracut module 'connman' will not be installed, because command 'connmand' could not be found!
dracut: dracut module 'connman' will not be installed, because command 'connmanctl' could not be found!
dracut: dracut module 'connman' will not be installed, because command 'connmand-wait-online' could not be found!
dracut: dracut module 'network-legacy' will not be installed, because command 'dhclient' could not be found!
dracut: dracut module 'network-wicked' will not be installed, because command 'wicked' could not be found!
dracut: 62bluetooth: Could not find any command of '/usr/lib/bluetooth/bluetoothd /usr/libexec/bluetooth/bluetoothd'!
dracut: dracut module 'lvmmerge' will not be installed, because command 'lvm' could not be found!
dracut: dracut module 'lvmthinpool-monitor' will not be installed, because command 'lvm' could not be found!
dracut: dracut module 'btrfs' will not be installed, because command 'btrfs' could not be found!
dracut: 90crypt: Could not find any command of '/lib/systemd/systemd-cryptsetup cryptsetup'!
dracut: dracut module 'dm' will not be installed, because command 'dmsetup' could not be found!
dracut: dracut module 'dmraid' will not be installed, because command 'dmraid' could not be found!
dracut: dracut module 'dmsquash-live-ntfs' will not be installed, because command 'ntfs-3g' could not be found!
dracut: dracut module 'lvm' will not be installed, because command 'lvm' could not be found!
dracut: dracut module 'mdraid' will not be installed, because command 'mdadm' could not be found!
dracut: dracut module 'multipath' will not be installed, because command 'multipath' could not be found!
dracut: dracut module 'pcsc' will not be installed, because command 'pcscd' could not be found!
dracut: dracut module 'tpm2-tss' will not be installed, because command 'tpm2' could not be found!
dracut: dracut module 'cifs' will not be installed, because command 'mount.cifs' could not be found!
dracut: dracut module 'fcoe' will not be installed, because command 'dcbtool' could not be found!
dracut: dracut module 'fcoe' will not be installed, because command 'fipvlan' could not be found!
dracut: dracut module 'fcoe' will not be installed, because command 'lldpad' could not be found!
dracut: dracut module 'fcoe' will not be installed, because command 'fcoemon' could not be found!
dracut: dracut module 'fcoe' will not be installed, because command 'fcoeadm' could not be found!
dracut: dracut module 'fcoe-uefi' will not be installed, because command 'dcbtool' could not be found!
dracut: dracut module 'fcoe-uefi' will not be installed, because command 'fipvlan' could not be found!
dracut: dracut module 'fcoe-uefi' will not be installed, because command 'lldpad' could not be found!
dracut: dracut module 'iscsi' will not be installed, because command 'iscsi-iname' could not be found!
dracut: dracut module 'iscsi' will not be installed, because command 'iscsiadm' could not be found!
dracut: dracut module 'iscsi' will not be installed, because command 'iscsid' could not be found!
dracut: dracut module 'nbd' will not be installed, because command 'nbd-client' could not be found!
dracut: 95nfs: Could not find any command of 'rpcbind portmap'!
dracut: dracut module 'nvmf' will not be installed, because command 'nvme' could not be found!
dracut: dracut module 'biosdevname' will not be installed, because command 'biosdevname' could not be found!
dracut: dracut module 'memstrack' will not be installed, because command 'memstrack' could not be found!
dracut: memstrack is not available
dracut: If you need to use rd.memdebug>=4, please install memstrack and procps-ng
dracut: dracut module 'squash' will not be installed, because command 'mksquashfs' could not be found!
dracut: dracut module 'squash' will not be installed, because command 'unsquashfs' could not be found!
dracut: *** Including module: systemd ***
dracut: *** Including module: systemd-initrd ***
dracut: *** Including module: i18n ***
dracut: *** Including module: kernel-modules ***
dracut: *** Including module: kernel-modules-extra ***
dracut: *** Including module: nvdimm ***
dracut: *** Including module: qemu ***
dracut: *** Including module: qemu-net ***
dracut: *** Including module: lunmask ***
dracut: *** Including module: resume ***
dracut: *** Including module: rootfs-block ***
dracut: *** Including module: terminfo ***
dracut: *** Including module: udev-rules ***
dracut: Skipping udev rule: 40-redhat.rules
dracut: Skipping udev rule: 50-firmware.rules
dracut: Skipping udev rule: 50-udev.rules
dracut: Skipping udev rule: 91-permissions.rules
dracut: Skipping udev rule: 80-drivers-modprobe.rules
dracut: *** Including module: virtiofs ***
dracut: *** Including module: dracut-systemd ***
dracut: *** Including module: usrmount ***
dracut: *** Including module: base ***
dracut: *** Including module: fs-lib ***
dracut: *** Including module: shutdown ***
dracut: *** Including modules done ***
dracut: *** Installing kernel module dependencies ***
dracut: *** Installing kernel module dependencies done ***
dracut: *** Resolving executable dependencies ***
dracut: *** Resolving executable dependencies done ***
dracut: *** Hardlinking files ***
dracut: Mode:                     real
dracut: Method:                   sha256
dracut: Files:                    1637
dracut: Linked:                   4 files
dracut: Compared:                 0 xattrs
dracut: Compared:                 446 files
dracut: Saved:                    6.9 KiB
dracut: Duration:                 0.046010 seconds
dracut: *** Hardlinking files done ***
dracut: *** Generating early-microcode cpio image ***
dracut: *** Constructing AuthenticAMD.bin ***
dracut: *** Constructing GenuineIntel.bin ***
dracut: *** Store current command line parameters ***
dracut: *** Stripping files ***
dracut: *** Stripping files done ***
dracut: *** Creating image file '/tmp/kernel-install.staging.GsZUqMa/initrd' ***
dracut: Using auto-determined compression method 'gzip'
dracut: *** Creating initramfs image file '/tmp/kernel-install.staging.GsZUqMa/initrd' done ***