Skip to end of metadata
Go to start of metadata

Understanding the Linux Boot Process

What happens between pressing the power button until the login screen

Different Stages:

System Startup

Post Code

Runtime Services

Load the first 512 Byte into the memory

Stage 1 Bootloader

Out of this 512 Byte 446 are the boot loader, 64 are the partition tables and 2 are the "magic number" 0X55AA
There are two types of boot loaders, filesystem aware and filesystem unaware.

Filesystem aware boot loaders need to have a driver to access the filesystem,
Filesystem unaware use using a map to see where the kernel lives.

Stage 2 Bootloader

choice of operating systems

load the initial ramdisk

Kernel and Initrd

enables to load modules for filesystems that the bootloader does not know, i.e. lvm for grub....

1) the boot loader loads the kernel and the initial RAM disk
2) the kernel converts initrd into a "normal" RAM disk and
frees the memory used by initrd
3) if the root device is not /dev/ram0, the old (deprecated)
change_root procedure is followed. see the "Obsolete root change
mechanism" section below.
4) root device is mounted. if it is /dev/ram0, the initrd image is
then mounted as root
5) /sbin/init is executed (this can be any valid executable, including
shell scripts; it is run with uid 0 and can do basically everything
init can do).
6) init mounts the "real" root file system
7) init places the root file system at the root directory using the
pivot_root system call
8) init execs the /sbin/init on the new root filesystem, performing
the usual boot sequence
9) the initrd file system is removed

Init

The first operation in userspace

Files and directories involved

/boot

here we have
vmlinuz-KERNEL-VERSION
System.map-KERNEL-VERSION
initrd.img-KERNEL-VERSION

config-KERNEL-VERSION

This is the configuration of the Kernel

abi-KERNEL-VERSION

Application Binary Interface
"exported functions that modules (AKA drivers) can use to do things in kernel space"

/etc/initramfs-tools/

here one can configure how the initramfs should look like, which modules to inclued, etc

/etc/rc*

The scripts are in /etc/init.d/

The init scripts that are going to be run

S start NN Number K Stop

things can be edited with update-rc.d or just by providing new links

IMPORTANT to disable a service:

to memorize when and where the service starts and stops
find /etc/rc* -iname "service" > /root/service-rc.conf
update-rc.d -f service remove
update-rc.d stop 50 0 1 2 3 4 5 6 .

don't forget the dot!

This will soon be done by upstart.

Sources

http://www.ibm.com/developerworks/linux/library/l-linuxboot/
http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-guide/s1-boot-init-shutdown-process.html
http://www.debianadmin.com/the-lniux-boot-process-explained.html
http://kernel-handbook.alioth.debian.org/ch-initramfs.html
https://wiki.ubuntu.com/KernelTeam/BuildSystem/ABI
http://en.wikipedia.org/wiki/Linux_startup_process
http://www.kernel.org/doc/Documentation/initrd.txt
http://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt