GRUB, ancient and modern GRUB Legacy Of course originally just GRUB - - PowerPoint PPT Presentation

grub ancient and modern
SMART_READER_LITE
LIVE PREVIEW

GRUB, ancient and modern GRUB Legacy Of course originally just GRUB - - PowerPoint PPT Presentation

GRUB, ancient and modern GRUB Legacy Of course originally just GRUB Started in 1995 by Erich Boleyn Multiboot Editable menus, reasonable FS interface BALGE Multiboot https://xkcd.com/927/ GRUB Legacy: stages Stage 1: MBR,


slide-1
SLIDE 1

GRUB, ancient and modern

slide-2
SLIDE 2

GRUB Legacy

  • Of course originally just GRUB
  • Started in 1995 by Erich Boleyn
  • Multiboot
  • Editable menus, reasonable FS interface
  • BALGE
slide-3
SLIDE 3

Multiboot

https://xkcd.com/927/

slide-4
SLIDE 4

GRUB Legacy: stages

  • Stage 1: MBR, just reads first sector of

Stage 1.5 and jumps to it

  • Stage 1.5: enough file system code to read

Stage 2 from an ordinary file system

  • Stage 2: rest of loader, e.g. Linux boot code
slide-5
SLIDE 5

GRUB Legacy: problems

  • Ad-hoc FS abstraction, multiple stage1.5s
  • Not much other abstraction worth mentioning
  • Difficult to extend safely
  • Lots of PC/BIOS assumptions
  • Divergence
slide-6
SLIDE 6

GRUB 2 rewrite

slide-7
SLIDE 7

New design

  • Small kernel, almost everything in modules
  • grub-install detects modules needed to

read /boot/grub/ and builds a core image

  • Heavy use of abstraction layers; highly

composable

  • Userspace tools built from same code
  • 10 kLoC asm, 250 kLoC C (excluding

libgcrypt)

– Includes all arches; i386-pc 4.5 kLoC asm

slide-8
SLIDE 8

Architecture support

  • x86: BIOS, UEFI, Coreboot, IEEE1275 (!),

Xen

  • PowerPC, SPARC: IEEE1275
  • IA/64: UEFI
  • MIPS: ARC, Yeeloong, Fuloong, Loongson
  • ARM: U-Boot, UEFI
  • ARM64: UEFI
slide-9
SLIDE 9

Normal hacking routine

  • Hardest Legacy problems were with reading

files from disk

  • Usually stuck with emulator + printf or (in

extremis) gdb

  • grub-probe and grub-fstest
  • Spin-off benefits: grub-mount
slide-10
SLIDE 10

When userspace doesn't help

  • bash-style interactive shell; set debug=foo
  • grub-mkrescue
  • Easy to run configuration files or even plug

in new commands

slide-11
SLIDE 11

Configuration

  • Debian update-grub → upstream, with

clearer input/output separation

  • Now /etc/default/grub and /etc/grub.d/
  • (Almost) all customisable
  • … but some customisation is hard
slide-12
SLIDE 12

PCs suck

  • MBR: no formal space for boot code

– Trivial loader in 446 bytes – Embed rest of brain in file system – Skate edge of (non-)spec: use boot track

  • Unpredictable with multiple disks
slide-13
SLIDE 13

PCs suck (2)

  • GPT much better, but different problems
  • Variant MBR interpretations

– Apple – boot flag on PMBR

slide-14
SLIDE 14

UEFI

  • New big thing on PCs; bye-bye legacy BIOS
  • Core support basically fine
  • “Secure Boot” works in Ubuntu, but needs

archive signing set up in Debian

  • Can require signed kernels without

impinging on freedom once MokManager is in place

  • ESP layout pain
slide-15
SLIDE 15

Non-x86

  • powerpc/sparc basically work fine, though

defaults not switched

  • Some mipsen work well, e.g. Yeeloong
  • Trend towards new architectures including

GRUB port early on

  • Most recent port (arm64) was about 2000

lines

slide-16
SLIDE 16

Debian pros/cons

  • Other loaders: LILO, syslinux and friends,

yaboot, etc.

  • Some pretty good, all smaller/simpler
  • … but result is complexity elsewhere
  • Any architecture, any disk layout
  • Portable loader allows common boot UI

across architectures and common tools

slide-17
SLIDE 17

Help wanted

  • Mostly just me right now in Debian; BUGS
  • Everyone's boot problem is critical for them
  • Overhaul configuration
  • MBR robustness
  • Rest of UEFI
  • Xen
  • Take better advantage of ports
slide-18
SLIDE 18

Discussion

Colin Watson <cjwatson@debian.org>