Hasty Briefsbeta

Bilingual

The Linux Boot Process: From Power Button to Kernel

6 months ago
  • #Kernel
  • #Linux
  • #Boot Process
  • The Linux boot process starts when the power button is pressed, initiating a sequence of steps from firmware to kernel execution.
  • CPU starts in real mode, using segment and offset registers to form memory addresses, and jumps to the reset vector at 0xFFFFFFF0.
  • BIOS or UEFI firmware performs hardware checks and loads the bootloader from the boot device.
  • Bootloader (e.g., GRUB) loads the Linux kernel into memory, which includes a setup program and a compressed kernel image.
  • Setup program prepares the environment by setting up segment registers, creating a stack, clearing BSS, and gathering memory information from firmware.
  • Transition from real mode to protected mode involves setting up the GDT and IDT, enabling paging, and switching CPU modes carefully to avoid interruptions.
  • Further transition to 64-bit long mode requires enabling paging and setting the LME bit in the EFER register.
  • The compressed kernel is decompressed, relocated if necessary, and the real kernel starts executing with start_kernel.
  • kASLR randomizes kernel memory addresses for security, using physical and virtual base addresses chosen from free memory regions.