DEV Community

Cover image for Behind the scenes: From Pressing the power button to Getting to the Login Screen

Behind the scenes: From Pressing the power button to Getting to the Login Screen


Ever wondered how your modern PC get to the Login screen with a mere press of a button? Are you curious of what happens behind the scenes of bootup or do you want to get called up by your friends when they face an error while booting up their PC? If yes, you're at the right place.

Boot up is not just a short-hand for Powering on a PC, it's actually a long and vital process. It's involves an extensive list of things that takes place to get a fully-functional session of an operating system. In this blog, we'll look upon the entire boot process from BIOS to Bootloader.

1) Pressing the Power button

When you press the Power button, the Power supply in the CPU cabinet supplies the power to it's units like-Hard disks, motherboard and SSDs to name a few.

Once, all the units gets power, CPU looks for a program called BIOS or UEFI(in modern systems).

2) BIOS/UEFI and Performing POST

BIOS screen

BIOS stands for Basic Input and Output System. Even though it hasn't evolved much, it has certainly changed it's residence many time from CMOS SRAM to NOR flash. It resided in CMOS SRAM in it early days but as SRAM was volatile, it's contents got flushed after turning OFF the computer.
BIOS then took it's place in PROM(non-erasable), UV-ROM(erasable by UV rays) and finally ended up in flash memory backed up by a CMOS battery.

BIOS performs POST(Power-on self-test) wherein it sends a signal to all devices and check's if they're up and running. If there's some error, it beeps and shows an error. The number of times it beeps signals the type of error. For example, if there's a RAM failure in a certain Dell laptop, it will beep 3 times signaling the error. You can know more about beep codes and corresponding errors here.

Now, once the BIOS is done testing the hardware, it hands over the control to the Operating system's bootloader.

3) Stage-1 Bootloader(Primary Bootloader)


BIOS looks for the Operating System to boot and load for which it has to select a Boot Device. This can be HDD, SSD, USB, CD or DVD drive.

For MBR partitioning system, we have the bootloader in the first sector of the hard disk called MBR Sector.

MBR sector is 512 bytes long and has primarily 3 partitions:

1) 446 byte for Primary Bootloader
2) 64 byte for Partition Table (4 tables of 16 bytes each)
3) 2 byte for Magic Number (Validation of MBR)

The main task of 446-byte long primary bootloader, also referred to as the stage-1 bootloader, is to find the secondary bootloader. It finds it by looking through the partition table.

4) Stage-2 bootloader(Secondary bootloader)


Now, once the Stage-2 bootloader is loaded, it actually loads the operating system.

It does this by loading the kernel and optional initial RAM disk(initramfs). The kernel starts the init system(systemd mostly) which starts other services leading all the way to login screen.

Ubuntu login screen

For Linux, we have GRUB bootloader, Windows uses Windows Boot Manager and Macs use boot.efi.

UEFI/GPT-based systems use something called EFI executable which doesn't have to be present in the first sector of the disk.

All these processes hardly take a few seconds. The evolution in the tech-world has made the computer boot up process lightning fast!

Top comments (0)