Linux Boot process for interview
"Our target is to load the OS"
1. Power on
2. ROM loads BIOS into the RAM - Boot strapping
3. POST - it does the "Hardware Inventory" on the system
4. CMOS, it will give the current bootable devices.
5. BIOS read first 512 bytes of HDD and its called MBR
6. 446 - BS, 64 PT and 2 bytes for Magic number.
7. Now BIOS examine the PT table to find out the Active Partition.
8. Loads whatever it finds in the first sector of the AP aka BS.
9. Now BIOS loads the first stage boot loader called LILO which is there in the BS of the MBR and put there at install time.
10. The fist stage boot loader has one purpose in life is to load the 2nd stage boot loader.
11. Now 1st stage boot loader request BIOS for CHS# of /boot/boot.b.
12. BIOS load this 2nd stage boot loader.
13. The 2nd stage boot loader now loads the balance contents of BS into the RAM.
14. Here it will go through the LILO.conf file and follows the instruction given there.
Prompt: It requests BIOS for an Int 13h and gives it the CHS # of the /boot/message file
which BIOS promptly fetches and the 2nd stage BL executes - This is the splash screen
15. after the timeout and default is Linux kernel then the 2nd stage boot loader - /boot/boot.b - loads the Linux kernel in the RAM
16. Now the 2nd-stage wishes to load the kernel, as instructed by the binary-format lilo.conf after timing out or whatever the user chooses.
But there's a problem !!
The Linux kernel is on the HDD /boot partition!!
And the 2nd-stage LILO BL has no idea how to access the HDD
Why ? Because of
The HDD drivers - /dev/hda... are in /dev on the HDD
and to access it the 2nd stage BL requires the file /dev/hda which once again is itself on the HDD !!
17. The 2nd stage BL has no choice but to use the BIOS as its HDD device driver to access the HDD at boot time.
After all that's where the kernel is [/boot/vmlinuz-2.4.20-8] !!
18. The 2nd stage BL once again requests BIOS - Int 13h fn 2 - for the CHS # of the
/boot/map file, which BIOS loads
22. The 2nd stage loader now examines this /boot/map and extracts the CHS # inside it - which was put there by the BL installer - anaconda - and /sbin/lilo - and requests BIOS once more to load whatever is there in that CHS # address
23. BIOS then loads the Linux kernel /boot/vmlinuz-2.4.20-8 into the RAM and hands it to the 2nd stage BL
24. The 2nd stage BL uncompress this file and fills the memory with kernel mem structures which can be seen in the /proc virtual file system
The Linux OS is ready and running!! Kernel Land is ready!!
Now it turns to user land....
25. Now Linux Kernel is in the RAM and more powerful than the 2nd stage BL. It takes over total control from it and makes yet another BIOS call Int 13h fn 2 for the file
/boot/initrd-2.4.20-8.img
26. It uncompress it in RAM and creates a mini-FS as can be seen by mounting initrd
image.
27. Note that the HDD driver is available now; Hence the kernel executes the "linuxrc" script which mounts the "root" partition in R/O mode and loads the /sbin/init* program into RAM
The Userland Part of Linux is now started by the /sbin/init daemon
Next Part !!! If you like the above Kernel Part ..please comment will post remaining part !!
No comments:
Post a Comment