Booting is the process of starting up a computer or device and loading its operating system. When a computer boots, it goes through a series of steps to load and initialize the operating system, device drivers, applications, and other settings.
What Happens When a Computer Boots?
Here is a typical sequence of events that occurs when booting a computer:
- Power on self test (POST) – The computer runs a diagnostic check to ensure its hardware components like RAM, CPU, keyboard, disk drives are working properly.
- BIOS initialization – The basic input/output system (BIOS) firmware initializes hardware components and looks for boot devices like hard disk, CD/DVD drive, or USB drive.
- Boot loader execution – A boot loader like GRUB loads and gives control over to the operating system kernel and init system.
- Kernel initialization – The core components of the operating system are loaded into memory.
- Init system and daemon processes start – Background processes and services required by the OS kickstart.
- Login prompt – User is prompted to enter login credentials.
- User session – Desktop environment, preferences, apps etc are loaded for the user to interact with.
This process takes some time to complete as the computer is accessing the hard drive, loading files into memory, and initializing all the kernel, services, and applications needed for stable operation. A typical boot process may take 30 seconds to a few minutes depending on the hardware specifications and operating system.
What is POST?
POST stands for Power-On Self Test. It is one of the very first steps of the boot process. When the computer is switched on, the CPU immediately passes control over to the BIOS firmware. The BIOS then runs POST to validate that the machine’s hardware is operational.
POST checks the following hardware components –
- Disk drives
- Network interface cards
- Video card
- Other PCI cards
If POST detects an issue such as bad RAM or CPU, it generates an error code or beep code to indicate failure. If everything checks out fine, it hands over control to the next stage of boot process.
What is the Role of BIOS?
BIOS stands for Basic Input/Output System. It is firmware programmed into a ROM chip on the motherboard when the computer is manufactured. When the POST completes successfully, the BIOS runs its initialization process and looks for bootable devices.
Key responsibilities of BIOS during boot –
- Detect and initialize RAM, PCI devices, USB ports, storage devices etc.
- Load BIOS settings like clock, time zone, boot order configured previously.
- Identify bootable storage devices like hard disk, optical disc drives or USB drives.
- Load and execute the boot loader program from the bootable device.
The BIOS ensures all essential hardware are available before looking for an operating system to boot from. Once it finds a valid boot device, it loads the boot loader residing on it to memory and passes execution to it.
What is the Role of Boot Loader?
The boot loader is a program that loads the operating system into memory. Some common boot loaders include –
- GRUB (GRand Unified Bootloader) – Used by Linux and BSD
- NTLDR (NT Loader) – Older Windows versions
- BOOTMGR (Boot Manager) – Modern Windows versions
The boot loader resides in the first sector of the boot disk, also known as Master Boot Record (MBR). When BIOS passes control to it, the boot loader does the following –
- Displays a boot menu allowing user to pick OS in case of multi-boot.
- Loads the kernel of the selected OS into memory.
- Initializes kernel parameters and hands over execution to kernel.
The boot loader acts as a bridge between the firmware initialization done by BIOS and loading of operating system by kernel.
The kernel is the central component of an operating system. It manages system resources like CPU, memory, I/O and allows applications to communicate with hardware. When the boot loader loads it into memory and gives it control, the kernel goes through its own initialization sequence –
- Initializes CPU registers and interfaces.
- Sets up memory paging for virtual memory.
- Detects and enumerates RAM modules and other hardware.
- Mounts the root filesystem defined in boot parameters.
- Starts essential kernel services and daemons.
- Performs final checks before initiating user space programs.
Once the kernel is up, it looks for the init system or process manager to handover control for booting the user space.
Init System and User Space
The init system is the first process that gets spawned by the kernel at boot time. It runs with root privileges and is the ancestor of all other processes. The main purpose of init is to setup user space where actual user programs and GUI will run.
Key tasks handled by the init system –
- Starts essential system services like udev, syslogd, networking, sshd etc.
- Launches daemon processes like crond, klogd, bluetooth services.
- Initializes the login prompt so user can provide credentials.
- Loads the desktop environment when user logs in.
- Manages service startup at different runlevels.
The init process brings up all the background infrastructure needed for apps, utilities, shells and desktop environments. Once ready, it presents the login screen to accept username and password from user. After successful login, the desktop loads up and user can begin interacting with the OS.
Types of Booting
There are a few different ways a computer can boot based on where the operating system files are loaded from –
In a cold boot, the computer starts from complete power off state. Electrical power is cycled and the computer boots from scratch. All steps of the boot process described above have to occur in sequence.
A warm boot means computer restarts without turning the power off and on. For e.g. the reboot command initiates a warm boot. In this case, POST and BIOS initialization is avoided as the hardware remains powered on. The boot loader loads the kernel directly skipping earlier steps.
Network boot refers to booting the OS from a network location instead of local storage. The network adapter loads a tiny bootstrap program which downloads a boot image containing kernel and init system over network to proceed further.
Single User Mode
Single user mode loads a minimal Linux environment without starting the graphical system. Only essential filesystems are mounted and a terminal console is presented for admin maintenance tasks.
Stages of Boot Process
Below is a summary of the key stages every PC goes through while booting up –
|Power on self test (POST)||Checks computer hardware components|
|BIOS initialization||Sets up essential device drivers|
|Boot loader||Loads operating system kernel|
|Kernel initialization||Mounts filesystems and starts services|
|Init system||Spawns login prompt and user space|
Boot Process in Windows
The boot process in Windows is similar overall but has some differences compared to Linux –
- Windows uses BCD (Boot Configuration Data) instead of boot loader like GRUB.
- BOOTMGR located in MBR loads Winload.exe kernel.
- Winload performs rest of kernel initialization.
- Wininit handles user space init responsibilities.
- Winlogon presents the logon screen and loads Explorer.exe
The boot files required by Windows like BOOTMGR and Winload are located in the hidden System Reserved partition. The various Windows services that need to start at boot time are defined in the registry.
Boot Process in Mac
Here are the essential steps when Macs boot up –
- Hardware initialization by EFI (Extensible Firmware Interface) instead of BIOS.
- Bootloader loads XNU kernel and mach_kernel.
- launchd handles init process duties on macOS.
- SystemManager starts I/O Kit kernel extension.
- loginwindow displays login screen.
- Finder runs the desktop on successful authentication.
One difference is macOS makes use of launchd for init tasks. The I/O Kit initializes drivers for Mac hardware. The Finder in macOS is analogous to Explorer.exe in Windows.
Fast Boot Methods
Boot times have improved greatly over the years with new technologies –
- UEFI – More advanced than BIOS with faster startup.
- Solid State Drives – No moving parts, much faster than mechanical drives.
- Hybrid Boot – Combines shutdown and hibernate states.
- Windows Fast Startup – Hibernates kernel on shutdown for faster restart.
These optimization techniques can make modern computers boot up extremely fast, sometimes in less than 10 seconds.
Boot Issues and Troubleshooting
Some common boot issues faced by users –
- Power issues – Broken power supply or loose connectors.
- Damaged hard disk – Bad sectors or corrupted filesystem.
- BIOS misconfiguration – Boot order not correct.
- Resource conflicts – Failing or incompatible hardware.
- Buggy updates – Faulty firmware, drivers or kernel upgrades.
- Malware infection – Viruses or rootkits interfering with boot.
Troubleshooting steps for boot problems –
- Check basics like power cables, RAM seating, CMOS battery.
- Look for visual signs like blink codes.
- Try booting from live Linux USB as a test.
- Get into BIOS settings menu to change boot order.
- Consult system logs and diagnostic tools for clues.
- Remove newly added components for possible incompatibility.
- Reinstall or roll back faulty drivers and patches.
- Use Windows startup repair, chkdsk, sfc utilities.
- Clean boot into safe mode to isolate software issues.
- Reset BIOS settings by clearing CMOS if needed.
For critical boot problems, booting from rescue media and running diagnostics is necessary. Resetting the BIOS and reinstalling operating system may be required in extreme cases.
The boot process brings a computer from complete power off to loading operating system, services and finally presenting login screen. Understanding the stages like POST, loading of bootloader, kernel and init system helps diagnose boot issues better. Newer technologies like UEFI and optimizations in recent operating systems have accelerated the booting sequence significantly over traditional BIOS process.