Fundamentals 19 min read

Unlocking Linux: A Deep Dive into Kernel Boot and Initialization (2.2.5 i386)

This article explains how to locate the Linux 2.2.5 i386 kernel source, describes the bootloader (bootsect-loader) and its related files, and walks through both real‑mode and protected‑mode initialization steps, including parameter tables and memory layout, to help readers understand the OS startup process.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Unlocking Linux: A Deep Dive into Kernel Boot and Initialization (2.2.5 i386)

Why Analyze the Linux Kernel Source?

Linux’s open source nature attracts many enthusiasts who enjoy dissecting and modifying the kernel; understanding the boot process and initialization provides deep insights into low‑level system design and programming practices.

Locating Kernel Source Files

The kernel source is typically installed under /usr/src/linux. Important top‑level entries include:

COPYING : GPL license.

CREDITS : List of contributors.

MAINTAINERS : Maintainer information.

Makefile : Build orchestration.

ReadMe and Rules.make : Basic documentation.

Arch/ : Architecture‑specific code (e.g., i386).

Include/ : Header files.

Init/ : Kernel initialization code ( main.c, Version.c).

Mm/ , Kernel/ , Drivers/ , Fs/ , Ipc/ , Lib/ , Net/ , Modules/ , Scripts/ : Various subsystems.

Boot Process Overview

Linux can be booted via LILO, Loadlin, or the built‑in bootsect‑loader. The loader’s source is /Arch/i386/boot/bootsect.S, which is placed in the MBR and hands control to the kernel.

Bootsect Loader Analysis

Key files involved:

/Arch/i386/boot/bootsect.S
/include/linux/config.h
/include/asm/boot.h
/include/linux/autoconf.h

The boot sequence loads the boot sector, moves itself to a higher address, sets up a temporary stack, builds a new disk‑parameter table, loads setup.S, and finally transfers control to setup.S.

Real‑Mode Initialization

Handled by /Arch/i386/boot/setup.S. It builds the INITSEG parameter table at segment 0x9000, storing hardware information such as video mode, memory size, and BIOS details. Important parameters include PARAM_CURSOR_POS, PARAM_VIDEO_MODE, PARAM_LFB_BASE, and flags indicating VGA presence or 32‑bit support.

Protected‑Mode Initialization

After switching to protected mode, the kernel runs code from /Arch/i386/boot/compressed/head.S and /Arch/i386/KERNEL/head.S. The main tasks are:

Decompress the kernel to 0x100000.

Set up page tables and enable paging.

Save hardware information gathered in real mode.

Detect CPU type and coprocessor.

Recreate the GDT and IDT.

Memory Layout After Initialization

Key structures placed in low memory include:

Page directory swapper_pg_dir at 0x101000 (4 KB).

Page table pg0 at 0x102000 (4 KB).

Empty pages and zero page for fault handling.

Hardware parameter block and command buffer around 0x105000.

Global descriptor table gdt_table at 0x106000.

Understanding these stages and data structures provides a clear picture of how Linux transitions from power‑on to a fully operational protected‑mode kernel.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

kernelAssemblyBoot Processprotected modereal mode
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.