Unified kernel image: Difference between revisions

From JookWiki
(Write introduction, start organization)
(Add boot order)
Line 2: Line 2:


== Overview ==
== Overview ==
The modern Linux boot process follows these steps:
# UEFI starts up
# UEFI loads a bootloader
# The bootloader shows a splash screen
# The bootloader loads microcode
# The bootloader loads an initramfs
# The bootloader sets up kernel arguments
# The bootloader loads the Linux kernel
# Linux configures itself using the kernel arguments
# Linux runs the init system in the initramfs
# The init system loads drivers
# The init system shows a splash screen
# The init system mounts partitions
# The init system switches to the actual root
- EFI stub
- EFI stub



Revision as of 00:42, 24 October 2022

If you use UEFI and only boot a single Linux kernel, you don't need a bootloader like systemd-boot or GRUB. Instead you can create a Unified Kernel Image and boot that directly. This article documents how.

Overview

The modern Linux boot process follows these steps:

  1. UEFI starts up
  2. UEFI loads a bootloader
  3. The bootloader shows a splash screen
  4. The bootloader loads microcode
  5. The bootloader loads an initramfs
  6. The bootloader sets up kernel arguments
  7. The bootloader loads the Linux kernel
  8. Linux configures itself using the kernel arguments
  9. Linux runs the init system in the initramfs
  10. The init system loads drivers
  11. The init system shows a splash screen
  12. The init system mounts partitions
  13. The init system switches to the actual root

- EFI stub

If you tend to only boot one kernel automatically when using Linux, yo

https://systemd.io/BOOT_LOADER_SPECIFICATION/#type-2-efi-unified-kernel-images

systemd's efistub + sections + whatever

kernel efistub

https://www.freedesktop.org/software/systemd/man/systemd-stub.html

Ubuntu install guide

apt install chmod +x /etc/kernel/postinst.d/zz-unified


#!/bin/bash

echo "root=UUID=b1e14117-8e88-4db6-9a6f-6bea5a0605e9 ro quiet bgrt_disable vt.handoff=7" > /tmp/cmdline.txt

objcopy \

   --add-section .osrel="/usr/lib/os-release" --change-section-vma .osrel=0x20000 \

   --add-section .cmdline="/tmp/cmdline.txt" --change-section-vma .cmdline=0x30000 \

   --add-section .splash="/boot/splash.bmp" --change-section-vma .splash=0x40000 \

   --add-section .linux="/boot/vmlinuz" --change-section-vma .linux=0x2000000 \

   --add-section .initrd="/boot/initrd.img" --change-section-vma .initrd=0x3000000 \

   "/usr/lib/systemd/boot/efi/linuxx64.efi.stub" "/boot/efi/EFI/unified/bootx64.efi"


- splash bmp can be anything

efibootmgr -c -d /dev/vda -p 2 -L "unified" -l "\efi\unified\bootx64.efi"

mkdir /boot/efi/EFI/unified


root@jookia-Standard-PC-Q35-ICH9-2009:/boot/efi/EFI/unified# efibootmgr -c -d /dev/vda -p 2 -L "unified" -l "\efi\unified\bootx64.efi" -^C

root@jookia-Standard-PC-Q35-ICH9-2009:/boot/efi/EFI/unified# efibootmgr -o 4

BootCurrent: 0004

Timeout: 3 seconds

BootOrder: 0004

Boot0000* UiApp

Boot0001* UEFI Misc Device

Boot0002* EFI Internal Shell

Boot0003* ubuntu

Boot0004* unified

Boot0005* UEFI PXEv4 (MAC:5254003512E6)