Linux 101
The Linux Boot Process
The Boot Process
MBR
BIOS Boot Sector Kernel
(Master Boot Record)
primary bootloader secondary bootloader bootable partition
(primary)
• Linux boot loaders can be installed into both the MBR or a boot sector
• Linux does NOT require the partition to be primary
• Most important Linux Boot Loaders are:
LILO GRUB
Linux Loader Grand Unified Bootloader
Detailed Boot Process
CPU BIOS BIOS BIOS
special
POWER executes performs initializes finds
hardware
BIOS POST hardware first MBR
OxFFFFFFF0
primary boot loader
loads
BIOS secondary boot loader
loads
primary boot
loader
Ox00007C00
Kernel
boot loader Initializes devices
loads
Mounts root partition
kernel
Executes initial program /sbin/init
LILO (Linux Loader)
Configuration file: /etc/lilo.conf
Global Configuration Per-image options
boot=/dev/hda overrides
prompt
timeout=50
message=/boot/message lilo [options]
lba32
default=linux stanza
image=/boot/vmlinuz-2.4.0-0.43.6
label=linux
initrd=/boot/initrd-2.4.0-0.43.6.img needs indent
read-only
root=/dev/hda5
other=/dev/hda1
label=dos
GRUB (Grand Unified Bootloader)
/boot/grub/menu.lst
Configuration file: /boot/grub/grub.conf
OR
Global Configuration Per-image options
overrides
default=0
timeout=30
title Red Hat Linux
root (hd0,0)
kernel /boot/vmlinuz-2.6.33 root=/dev/sda3
grub
grub-install <device>
The init Program
/sbin/init PID 1
Reads runlevel configuration from: /etc/inittab
Stage of OS operation that defines the funcionality provided by the system
Runlevels
0 - shutdown
1 - single user (1, S, s, single)
2 - Debian – full X GUI
3 - full multi-user, console init <runlevel>
4 - undefined
5 - Red Hat – full X GUI
6 - reboot
The inittab File
/etc/inittab
Some distributions migrated from inittab to event.d
Ubuntu has no inittab
id:runlevels:action:process
entry applied to process to run
how to treat
function
the process
(wait, respawn)
SysV Startup Scripts
/etc/init.d/rc
Main script: /etc/rc.d/rc OR
/etc/init.d/rc?.d
Service scripts: /etc/rc.d/rc?.d
/etc/rc?.d
OR
? = runlevel number
Script filename: (S | K)[0-9]*name
chkconfig --list
chkconfig --level <levels> <script> (on | off)
chkconfig --add <script>