The Linux Boot Process
Ali MEZGANI
[email protected]
May 19, 2008
1 / 14
Summary
BIOS (basic input/output system) Master Boot Record (MBR) Boot loader Kernel Init Run Levels The login process
2 / 14
Boot process
3 / 14
BIOS
On boot, the CPU initialize it self Most registers in the CPU have well-defined values after power up CPU execute a code at address 0xFFFF0 This location is a jump to the BIOS which reside in ROM on the motherboard.
4 / 14
BIOS
Power-on Self Test (POST) and check material (graphic card, processor, memory, ...) After the POST is complete, POST related code is flushed out of memory. Load boot sector from one of : Floppy, CDROM, Hard drive, Network, usb The boot order can be changed from within the BIOS.
5 / 14
Master Boot Record (MBR)
BIOS load and execute the first 512 bytes of the disk (sector 0), and returns control to MBR Standard DOS MBR will look for a primary partition (/dev/hda1..4) marked bootable Load and execute first 512 bytes of this partition Can be restored with fdisk /mbr from DOS Load the boot loader (lilo, grub ...)
6 / 14
Boot loader
Load kernel and the initial ram disk to memory Pass the control to the kernel image Lilo : doesn’t understand filesystem Grub : understand filesystem
7 / 14
Kernel Initialize Stack and BSS Decompress kernel image initialize devices Initramfs or initrd find the location of the filesystem and pass that to the kernel as its root filesystem. The kernel read its root filesystem Execute init process, run /sbin/init pid=1 8 / 14
Init
Kernel read /etc/inittab Run boot scripts in /etc/init.d/ On debian: run /etc/init.d/rcS which runs: /etc/rcS.d/S* scripts Run programs specified in /etc/inittab
9 / 14
Run levels
0 halt 1 single user 2 full Multi-User mode (default) 3-5 same as 2 6 reboot
10 / 14
Run level programs
Scripts prefixed with S will be started when the runlevel is entered, eg /etc/rc5.d/S99xdm Scripts prefixed with K will be killed when the runlevel is entered, eg /etc/rc6.d/K20apache X11 login screen is typically started by one of S99xdm, S99kdm, S99gdm or S99jwm 1:2345:respawn:/sbin/getty 9600 tty1
11 / 14
Run level programs
After the init process executes all the commands, files and scripts, the last few processes are the /sbin/mingetty ones, which shows the banner and log-in message of the distribution you have installed. The system is loaded and prepared so the user could log in.
12 / 14
Additional Resources
http://www.debianadmin.com/the-lniux-boot-process-explained.html http://www.ibm.com/developerworks/linux/library/l-linuxboot/ http://duartes.org/gustavo/blog/post/how-computers-boot-up http://www.pixelbeat.org/docs/disk/
13 / 14
Colophon
Presentation produced using the Beamer class in LATEX using the Kile editor on Debian 5.0.
14 / 14