initramfs-tools
Ben Hutchings
What is the initramfs for?
-
Huge variety of disk drivers, net drivers and filesystems that
may be needed to mount root
-
Generic kernel shouldn't have all these built-in
-
Root might also need RAID, LVM, dm-crypt, which generally need
to be configured by userland
-
Kernel needs a way to load modules and run scripts but
it can't read them from the root filesystem
-
Solution: boot loader provides a bundle of files
(initramfs image) to the kernel
How the kernel uses an initramfs
-
Kernel always mounts an initial root filesystem using
either ramfs or tmpfs
-
If the boot loader provides an initramfs image, kernel
unpacks it into this filesystem, then runs /init
-
The initramfs init system is then responsible for mounting
the real root filesystem and running the real init
-
Although it is not required to hand over at all
- e.g. debian-installer
Overview
-
Started in Ubuntu in 2005 and adopted in Debian later that year
-
mkinitramfs builds an initramfs image using the
included scripts, necessary kernel modules, udev, and utilities
from klibc-utils or busybox
-
Uses build-time and boot-time hook scripts for
extensibility
- Used by btrfs-tools, cryptsetup, lvm2, mdadm, etc.
-
Supports dependencies within each set of scripts
The init system
-
Mount devtmpfs, devpts, procfs,
sysfs, tmpfs at /run
-
Run init-top scripts - includes starting udev
-
Load explicitly configured modules
-
Run init-premount scripts
-
Run local-top or nfs-top scripts
- e.g. mdadm setup
-
Run local-premount or nfs-premount scripts
- e.g. btrfs scan, resume from disk
-
Mount root filesystem
Questions?
Credits
-
Linux 'Tux' logo © Larry Ewing, Simon Budig.
- Modified by Ben to add Debian open-ND logo
-
Debian open-ND logo © Software in the Public Interest, Inc.
-
Xzibit promotional photo © Retna, used for purpose of parody