I just to want to know the flow of activities happening after loading the linux kernel image into the RAM after boot process.
As of Linux 2.6:
After loaded into RAM, the kernel executes the following functions.
- Build a table in RAM describing the layout of the physical memory.
- Set keyboard repeat delay and rate.
- Initialize the video adapter card.
- Initialize the disk controller with hard disk parameters.
- Check for IBM Micro Channel bus.
- Check for PS/2 pointing devices (bus mouse).
- Check for Advanced Power Management (APM) support.
- If supported, build a table in RAM describing the hard disks available.
- If the kernel image was loaded low in RAM, move it to high.
- Set the A20 pin (a compatibility hack for ancient 8088 microprocessors).
- Setup a provisional Interrupt Descriptor Table (IDT) and a provisional Global Descriptor Table (GDT).
- Reset the floating-point unit (FPU).
- Reprogram the Programmable Interrupt Controllers (PIC).
- Switch from Real to Protected Mode.
- Initialize segmentation registers and a provisional stack.
- Clear all bits in the
- Fill the area of uninitialized data with zeros.
decompress_kernel()to decompress the kernel image.
startup_32() (same name, other function):
- Initialize final segmentation registers.
bsssegment with zeros.
- Initialize provisional kernel Page Tables.
- Enable paging.
- Setup Kernel Mode stack for process 0.
- Again, clear all bits in the
- Fill the IDT with null interrupt handlers.
- Initialize the first page frame with system parameters.
- Identify the model of the processor.
- Initialize registers with the addresses of the GDT and IDT.
Nearly every kernel component gets initialized by this function, these are only a few.
- Memory zones
- Buddy system allocator
- Date and Time
- Slab allocator
- Create process 1 (
The complete "list" is available in the sources at linux/init/main.c
Init starts all the necessary user process to bring the system into the desired state, this routine highly depends on the distribution and the runlevel invoked.
runlevel into the console, this gives you the current runlevel of your system.
Take a look into
/etc/rc.d/rcX.d/), replacing the X with your runlevel.
These are symlinks ordered by execution priority.
S01.... means, this scripts gets started very early, while
S99.... runs at the very end of the boot process. The
KXX.... symlinks do the same but for the shutdown sequence.
Generally, these scripts handle disks, networking, logging, device control, special drivers, environment and many other required sequences.
- Kernel takes in the control of the system H/W as soon as you see "Uncompressing Linux..".
- Kernel checks and sets the the BIOS registers of graphics cards and the screen output format.
- Kernel then reads BIOS settings, and initializes basic hardware interfaces.
- Next the drivers in the kernel initialize the hardware.
- Then the Kernel check for the partitons
- Then it mounts the root file system
- Then the kernel starts init, which boots the main system with all its programs and configurations.