Have you ever given it a thought that when you press the power button on your laptop or PC, what happens behind the logo of Windows XP/Vista/Seven or Linux. From the pressing of the power button to the appearance of the login screen there are more than hundred components/peripherals that are initialized and thousand lines of code is executed. We will look inside the machine, that actually what all happens. So let us start…
What is Booting?
Booting is a process or set of operations that loads and hence starts the operating system, starting from the point when user switches on the power button.
Note: Basically documents related to booting are generally confusing as they are often related to some specific operating system that is Linux machine or Windows machine. But I will keep it as general as possible.
General Booting sequence comprises of the following steps:
· Turn on the Power button.
· CPU pins are reset and registers are set to specific value.
· CPU jump to address of BIOS (0xFFFF0).
· BIOS run POST (Power-On Self Test) and other necessary checks.
· BIOS jumps to MBR(Master Boot Record).
· Primary Bootloader runs from MBR and jumps to Secondary Bootloader.
· Secondary Bootloaders loads Operating System.
These are the tasks that are carried during booting process. Now let us discuss them in detail.
BIOS-Basic Input Output System
As soon as the power button is pressed then first power is checked and hence the CPU is powered up. CPU is reset and its registers are set to the default value, which is an address pointing or directing to the hardware containing BIOS. Generally the hardware is EEPROM containing the BIOS. The tasks performed by BIOS are categorized as follows:
· POST- Power on Self Test is the foremost routine which checks and tests the basic hardware. If it fails then it displays error.
· Initialization of the hardware devices by letting them run their individual BIOS( eg. video card have their own inbuilt BIOS code).
· Searching for the Master Boot Record and reading it.
· Copying the boot sector code to RAM and then switching the control to it.
A sector is a part of the hard disk having length of 512 bytes. A sector is termed as boot sector because of its location and because this sector is responsible for the further boot process of the system. This boot sector is generally called Master Boot Record. The MBR is a 512-byte sector, which is located in the first sector on the disk (sector 1 of cylinder 0, head 0). As soon as BIOS gets the boot sector, it tends to copy MBR to RAM and switches the execution authority to it.
· In the MBR the first 446 bytes are the primary boot loader, which is also referred as PBL.
· The next sixty-four bytes are the partition table, which has the record for each of the partitions.
· The MBR ends with two bytes that should be 0xAA55. These numbers act as validation that this sector is the boot sector or Master Boot Record.
If machine has 2 operating system, then the Primary Bootloader gives user a choice to select which operating system user wants, and after his/her selection jumps to the Secondary Bootloader-which is specific to an operating system.
Let us consider an example.
· If a machine has Windows/Linux machine, then it will have only one bootloader that is DOS/GRUB bootloader which will load the operating system.
· If a machine has 2 operating systems then the primary bootloader will give user a choice to select which operating system he/she wants that is either Windows or Linux, and corresponding to OS bootloader (secondary) DOS or GRUB will load the operating system.
As the Secondary bootloader becomes active, it jumps to the location where image of the operating system is found.
· In case of Linux the task that follow this are decompression of kernel, establishment of filesystem and then setting of device drivers.
· In case of Windows system starts in 16-bit real mode and then moves into 32-bit protected mode, and after choosing hardware profile loads the device driver.
This is how computer boots up and we see our login screen.
Filed Under: How to