I want to know the basics linux booting process. I googled for this but i didn't find the detailed things anywhere. I want to know the boot process including the hardware work flow. Can anyone give me the detailed tutorial to learn about this.First, when you power up the system the bios goes through a POST, which is power-on self test. This just checks that hardware is working, etc. Then it looks for a boot sektor, which must be 512 bytes long and end with a magic number, and loads the kernel. From there, you can look at the head.s assembly, and I think someone posted a tutorial here a while back--maybe they'll post that again.
- The POST (Power-On-Self-Test) is done. POST checks all the processors that are connected, the amount of RAM available, disks that are connected, network cards available etc.
- Then the BIOS (Basic Input/Output Services) program is loaded. The BIOS searches for IDE, SCSI, PATA drives. Then it searches for active (bootable) partition(s). Using this knowledge, it checks the information in the Master Boot Record (MBR) of the drive (that has the active partition(s)). Then, it loads the bootloader (mostly GRUB - Grand Unified Bootloader) from the MBR.
- Grub knows how to read all kinds of partitions. So, it can boot from any file system.
- It checks and loads the settings in /boot/grub/grub.conf. This file contains path for root = (hd0,0), kernel = vmlinuz, initrd = initrd.img (cpio archive).
- The Linux kernel is loaded into the RAM. It knows how to unpack the cpio archive which was specified by initrd parameter in grub.conf. The kernel loads this unpacked initial RAM disk and root file system (also called initramfs) into the RAM. Then it starts executing the /etc/init file present in this initramfs.
- initrd: It contains the initial RAM disk and the initial root file system. These are loaded into the RAM before the actual root file system from the hard disk is loaded.
- ntldr: In case another bootloader is required to be loaded, then the 'chainloader+1' command tells grub to load the bootloader mentioned. ntldr is the Windows bootloader. In Windows, all drives are loaded in user-space.
- init starts populating /dev with the devices that are connected. init inserts kernel modules (.ko files) to detect the connected hardware.
- init loads the hard disk. Then, init "switches root" to the root file system in the hard disk. Finally, before terminating, this init file of the initramfs passes control to the init file in the hard disk.
- init loads the partitions which are mentioned in /etc/fstab.
- Then, all the files up to and including the required "init level" are executed.
- These include rc.sysinit, rc.local (directory) and rcX.d (directory - where X refers to a whole number).
- If you check the /etc/rc0.d directory, you will find symlinks starting with either a 'K' or a 'S'. This is followed by a number. This convention is followed purposely. All symlinks with a starting K are 'kill' commands. All symlinks with a starting S are start commands. All the symlinks are followed in lexicographic order. So, all the kill commands are executed first (K00*, K01* etc.), followed by the start commands (S00*, S01* etc.).
- So, if you want to boot to init level 1, then all the commands in /etc/rc1.d directory are executed. If you want a Graphical Environment (i.e., init level 5), then all commands from rc1.d up to rc5.d are executed.
- init level 0 is for shutdown and init level 6 is for restart (i think; not sure about init level 6).
Hope this helps!
Rigved Rakshit
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies