Tuesday, August 31, 2010

Booting Sequence of Unix/Linux based Systems

A closer look at GRUB


● GRUB understands ext2 and ext3 file systems

● LILO had to load raw sectors from the hard disk

● GRUB displays a list of available kernels

● On Ubuntu, defined in /boot/grub/menu.lst
● More info: http://www.gnu.org/software/grub/
 
 
What does GRUB load?


title Ubuntu 9.04, kernel 2.6.2813generic

uuid 0ef7b971

kernel /boot/vmlinuz2.6.2813generic

root=UUID=0ef7b971 ro quiet splash

initrd /boot/initrd.img2.6.2813generic

● kernel – a compressed kernel image

● Performs initial minimal hardware setup

● Decompresses the kernel image, puts it in memory

● If present, loads RAM disk (see below)

● initrd – initial RAM disk

● Temporary root file system

● Contains executables and drivers to load the real root
 
Execution in the kernel


● arch/i386/boot/head.S

● performs basic hardware setup

● calls startup_32() of ./arch/i386/boot/compressed/head.S

● arch/i386/boot/compressed/head.S

● set up the basic environment

● clear Block Started by Symbol

● calls decompress_kernel() found in ./arch/i386/boot/compressed/misc.c

● calls startup_32 in ./arch/i386/kernel/head.S

● arch/i386/kernel/head.S

● also called swapper or process 0

● initializes page tables and enables memory paging

● detects CPU type

● init/main.c

● calls start_kernel()

● calls kernel_thread to start init (process ID 1)
 
initrd


● Initial RAM disk – a small temporary file system

● During stage 2 boot, initrd is copied into RAM

and mounted

● Allows the kernel to fully boot without having to

mount any physical disks

● Supports many hardware configurations

through loadable modules

● After kernel is booted, the real root file system

is mounted
 
init


● The first user space program -- /sbin/init

● Typical for desktop Linux systems

● For Ubuntu, init reads /etc/event.d

● see https://launchpad.net/upstart/

● default run level defined at /etc/event.d/rc-default

● for normal start, Ubuntu is at run level 2

● executes programs from /etc/rc2.d

● For other Linux systems, init reads /etc/inittab
 
Sources


● “Inside the Linux Boot Process”, M. Tim Jones, IBM Developerworks

● http://www.ibm.com/developerworks/linux/library/l-linuxboot/

● “Linux initial RAM disk overview”, M. Tim Jones, IBM Developerworks

● http://www.ibm.com/developerworks/linux/library/l-initrd.html

No comments:

Post a Comment