Monday, April 29, 2013

Linux Booting Process

1. First BIOS runs POST (Power-On Self-Test).
  • verify CPU registers
  • verify the integrity of the BIOS code itself
  • verify some basic components like DMA, timer, interrupt controller
  • find, size, and verify system main memory
  • initialize BIOS
  • pass control to other specialized BIOSes (if and when required)
  • identify, organize, and select which devices are available for booting


2. BIOS determines boot device.
If storage device like hard disk, BIOS loads "boot loader" program from MBR of hard disk In linux, typical boot loader program is "grub" (Grand Unified Boot Loader).

3. Grub further figures out how to fetch the kernel and the initrd image.

4. kernel mounts initrd to get a temporary root file system.

5. kernel is also tells where the actual root file system is (in grub config).

6. then kernel mounts root file system and runs /sbin/init (can be overridden by
passing init=/path/to/some/other/program).

7. init is the first process and it reads /etc/init/*.conf and /etc/init/rc-sysinit.conf contains runlevel information init effectively runs all executable files in /etc/rcRUNLEVEL.d/S* and stops /etc/rcRUNLEVEL.d/K*
some of these programs run by init setup various things needed by the OS, such as pseudo-tty devices, configure network, start needed daemons, etc.,

8. Thus all the services needed for OS has been started.

OS BEGINS.