Saturday, March 10, 2012

linux boot process

Linux boot process:
1. loading mbr info about bootloader
-->mbr is the first sector of your primary HDD (1sector = 512bytes),it contains 64B of partition info(what is located where on you drive)
Bootloader is GRUB in my case.Its a 2 stage process, the first stage is pointing to the conf file (menu.lst or grub.conf) that tells you what all options (kernel,OS) you have that you can boot into.

2. bootloader choose of kernel version
-->Now you have made a choice.The stage 2 of bootloader proceeds to copy the initrd and kernel intot the memory.
3. initializing kernel and initrd image
4. loading kernel modules
initrd loads the required modules in the kernel.
5. discovering hardware
6. looking for disks
7. R/O mount of / partition
intird has lsmod built into it and it is mainly responsible for loading the required modules into the kernel.Once all modules are loaded the kernel is able to talk to all the initrd is relived off the memory to reduce the memory footprint and the kernel proceeds to mount the root file system (/) on the HDD.Once / is mounted it does a find for init in the /sbin directory and runs the init process.
8. init process spawn
9. /etc/inittab read and executing
10. mounting all FSes from /etc/fstab
11. runlevels running (based on default runlevel in /etc/inittab)
12. rc.local
13. login prompt
14. runs /etc/profile and then all the scripts in /etc/profile.d