| Booting Sequences: -------------------------- The following covers about the booting steps happening when the computer is powered on and explains how the kernel is loaded into the memory and it various stages. Normally booting refers to the process of how the operating system is getting loaded when we switch on the computer. There are various stages involved in this process. The operating system is stored either in hard disk or in Live cds, or in USB flash drives. It doesnt reside in memory when the system is powered up. The hardware doenst have any knowledge of how to load the operating system from hard disk into memory. Here comes a small program stored in ROM(permanent storage) in the mother board called as bootloader or bootstrap loader, which is written in such a way to load the other software which is required for the operating system to start. As and when the computer is powered on, the CPU is designed to execute the code present in the predefined address which is nothing but the code present in the ROM . One such example bootstrap loader is BIOS of an IBM pc. In pc having 386 CPU, it executes the instruction at address 0xFFFF0000 of ROM (BIOS) when switched on. The control is given to the startup program of the BIOS. Basically it does two steps 1) POST (power on self test) - To check for deivces the computer depends on are functioning and initalising these devices. 2) Probe of bootable device and load the bootsector. - Then BIOS goes through the preconfigured list of devices to identify a bootable device and then load the next boot sequence from the boot sector of the device. MBR - Master Boot Record is considered to be first stage boot loader identified in the boot sector of the bootable device. MBR code usually checks for the active partion from partion table. If an active partion is found, then it loads the bootsector code from the active partition. Usually it is 512 bytes & the first sector in the disk (sector 1 of cylinder 0, head 0). The partiton table size is 64 bytes whihc contains the list of partitions available in the disk and boot loader code is 446 bytes and 2 bytes for magic number. (512 bytes ) Second stage bootloaders are the ones usually identified in the boot sector of the active partion. Some of the famous such boot loaders are LILO,GRUB(for linux ),NTLDR(for windows NT based). These bootloaders will be able to load the operating system and finally transfers controls to it. And all these bootloaders can be configured to give users multiple booting choices which allows users to choose a operating sytem from multiple operating system(multi booting from different partitions or hard drives), to choose a kernel of different versions of the same operating system. So ultimately these bootloaders are aimed to acheive loading the kernel of the operating system chosen by the user. The boot process is said to be complete when the kernel is loaded fully and a user application could be executed by operating system. I can put the above statements in a simple picture as below System startup (BIOS) --- > Ist stage boot loader (MBR) ---> 2nd stage boot loader (LILO,GRUB etc) --> Kernel (Linux) --> Init (User space ). Now we come to discussions of how linux kernel getting loaded into the memory from second stage boot loader and what are the various job it perform as it gets loaded. The second stage bootloader(like GRUB.) copies the kernel image and its associated initrd(initial RAM disk) image into the memory and gives control to the kernel image by calling the 'start' assembly routine find in the corresponding platform dependent code in ./arch/i386/boot/head.S |
||