Winter Semester 2026–27 · VIT-AP · BACSE106 · Operating Systems · Dr. Krithika L.B

Building and booting an OS

Step through power-on → firmware → boot loader → kernel → systemd.

Module 1 Session 1.4 Lesson 4 of 4

Building and booting an operating system

From source code to a running kernel, and from power-on to the login prompt.

Part 1 — Building (system generation)

An OS is usually generic: it must be configured for the machine it runs on. The process of configuring and producing the kernel is called system generation (SYSGEN). For Linux it looks like this:

Write the OS from scratch, or download existing source (e.g. from kernel.org).

make menuconfig asks which CPU, drivers, file systems and features to include, and whether each should be built into the kernel or as a module. Answers are saved in .config.

make -j$(nproc) compiles thousands of C and assembly files and links them into a compressed kernel image (bzImage / vmlinuz) plus .ko module files.

make modules_install copies modules to /lib/modules/<version>; make install copies the kernel to /boot, builds an initramfs and adds a GRUB entry.

Reboot, pick the new entry in GRUB, and confirm with uname -r.

Three ways to generate a system
  • Fully tailored: recompile for the exact hardware — smallest and fastest, least general.
  • Table-driven: one precompiled kernel chooses code from tables at boot.
  • Modular: generic kernel; hardware-specific modules loaded at boot or run time — what most distributions do.

Part 2 — Booting

The CPU resets and begins executing at a fixed address mapped to firmware stored in ROM/flash on the motherboard. RAM contents are undefined.

BIOS (legacy) or UEFI runs the POST (power-on self-test), initialises the chipset, memory and basic devices, and walks the configured boot order.

BIOS: reads sector 0 of the boot disk (512 bytes, the MBR) to physical address 0x7C00, checks bytes 510–511 for 0x55 0xAA, and jumps there in 16-bit real mode. The MBR also holds the partition table.

UEFI: reads the FAT-formatted EFI System Partition and runs a boot application such as grubx64.efi; Secure Boot can verify its signature first.

GRUB shows a menu, reads its configuration, loads the kernel image and the initramfs into memory, passes the kernel command line (e.g. root=UUID=… ro quiet) and jumps to the kernel entry point.

The kernel decompresses itself, switches the CPU into its full operating mode, sets up page tables and the interrupt vector, initialises the scheduler, probes devices, uses the initramfs to load storage drivers and mounts the real root file system.

The kernel starts the first user-space process, /sbin/init — on most distributions systemd with PID 1. It starts services (networking, logging, display manager) in parallel. Every other process is a descendant of PID 1.

A login prompt or desktop appears. The kernel now runs only when an interrupt, a system call or an exception occurs — the event-driven loop from Session 1.4.

Legacy BIOS vs UEFI

Legacy BIOSUEFI
Boot code locationFirst 512-byte sector (MBR)Files on the EFI System Partition (FAT)
CPU mode at hand-off16-bit real mode32/64-bit mode
Disk partitioningMBR, max 2 TiB, 4 primary partitionsGPT, very large disks, 128+ partitions
SecurityNoneSecure Boot verifies signed loaders
The shape of a legacy boot sector (what you build in Lab 2)
offset 0x000 ... 0x1BD   boot code + data   (446 bytes)  <- your program runs here, loaded at 0x7C00
offset 0x1BE ... 0x1FD   partition table    (4 x 16 bytes)
offset 0x1FE            0x55                 \  boot signature
offset 0x1FF            0xAA                 /  (BIOS refuses the sector without it)
Quick check

At which physical address does a legacy BIOS place the boot sector?

The BIOS copies the 512-byte sector to 0x7C00 and jumps there.

Which component loads the kernel image and initramfs?

Firmware loads the boot loader; the boot loader loads the kernel.

What is the process ID of systemd on a typical Linux system?

It is the first user-space process the kernel starts — PID 1.

Why is an initramfs needed?

The root disk may need a driver (e.g. NVMe, RAID, encryption) that is a module — the initramfs supplies it early.