Linux BOOT Process

Boot sequence summary

When a PC is booted it starts running a BIOS program which is a memory resident program on an EEPROM integrated circuit. The BIOS program will eventually try to read the first sector on a booting media such as a hard or floppy drive. The boot sector contains a small program that the BIOS will load and attempt to pass run control to. This program will attempt to read the operating system from the disk and run it. LILO is the program that Linux systems typically use to give users a choice of operating systems to run. It is usually installed in the boot sector which is also called the master boot record. If the user chooses to boot Linux, LILO will attempt to load the Linux kernel causing the following basic events to happen:

BIOS

Load boot sector from one of:
Floppy
CDROM
Hard drive
The boot order can be changed from within the BIOS. BIOS setup can be entered by pressing a key during bootup. The exact key depends varies, but is often one of Del, F1, F2, or F10.
Loading sequence
load menu code, typically /boot/boot.b
prompt for (or timeout to default) partition or kernel
for "image=" (ie Linux) option load kernel image
for "other=" (ie DOS) option load first 512 bytes of the partition
copy kernel image (bzImage) and modules to /boot and /lib/modules
edit /etc/lilo.conf
duplicate image= section, eg:
image=/bzImage-2.4.14
label=14
read-only
man lilo.conf for details
run /sbin/lilo
reboot to test

GRUB

Understands file systems
config lives in /boot/grub/menu.lst or /boot/boot/menu.lst

Kernel

initialise devices
(optionally loads initrd, see below)
mounts root filesystem
specified by lilo or loadin with root= parameter
kernel prints: VFS: Mounted root (ext2 filesystem) readonly.
runs /sbin/init which is process number 1 (PID=1)
init prints: INIT: version 2.76 booting
can be changed with boot= parameter to lilo, eg boot=/bin/sh can be useful to rescue a system which is having trouble booting.

initrd

Allows setup to be performed before root FS is mounted
lilo or loadlin loads ram disk image
kernel runs /linuxrc
load modules
initialise devices
/linuxrc exits
"real" root is mounted
kernel runs /sbin/init
Details in /usr/src/linux/Documentation/initrd.txt (part of the kernel source).

/sbin/init

reads /etc/inittab (see man inittab which specifies the scripts below
Run boot scripts:
debian: run /etc/init.d/rcS which runs:
/etc/rcS.d/S* scripts
/etc/rc.boot/* (depreciated)
redhat: /etc/rc.d/rc.sysinit script which: loads modules, check root FS and mount RW, mount local FS, setup network, and mount remote FS
switches to default runlevel eg 3.
run scripts /etc/rc3.d/S*
run programs specified in /etc/inittab

Run Levels

0 halt
1 single user
2-4 user defined
5 X11 only (0 or 1 text console)
6 Reboot
Default is defined in /etc/inittab, eg:
id:3:initdefault:
The current runlevel can be changed by running /sbin/telinit # where # is the new runlevel, eg typing telinit 6 will reboot.

Run Level programs

Scripts in /etc/rc*.d/* are symlinks to /etc/init.d
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, or S99gdm.
Run programs for specified run level
/etc/inittab lines:
1:2345:respawn:/sbin/getty 9600 tty1
Always running in runlevels 2, 3, 4, or 5
Displays login on console (tty1)
2:234:respawn:/sbin/getty 9600 tty2
Always running in runlevels 2, 3, or 4
Displays login on console (tty2)
l3:3:wait:/etc/init.d/rc 3
Run once when switching to runlevel 3.
Uses scripts stored in /etc/rc3.d/
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
Run when control-alt-delete is pressed

Boot Summary

lilo
/etc/lilo.conf
debian runs
/etc/rcS.d/S* scripts
/etc/rc3.d/S* scripts
redhat runs
/etc/rc.d/rc.sysinit script
/etc/rc.d/rc3.d/S* scripts

Comments

Popular posts from this blog

Installation of Linux version of XAMPP

How can I prevent users from connecting to a USB storage device? in Windows OS

Basic Linux Commands