Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I just to want to know the flow of activities happening after loading the linux kernel image into the RAM after boot process.

share|improve this question
2  
You shouldn't want to know that. What you should want is learn it. –  alex Dec 28 '10 at 12:03
    
thanks for the comment –  Renjith G Dec 29 '10 at 5:54
add comment

3 Answers 3

up vote 11 down vote accepted

As of Linux 2.6:

Kernel

After loaded into RAM, the kernel executes the following functions.

setup():

  1. Build a table in RAM describing the layout of the physical memory.
  2. Set keyboard repeat delay and rate.
  3. Initialize the video adapter card.
  4. Initialize the disk controller with hard disk parameters.
  5. Check for IBM Micro Channel bus.
  6. Check for PS/2 pointing devices (bus mouse).
  7. Check for Advanced Power Management (APM) support.
  8. If supported, build a table in RAM describing the hard disks available.
  9. If the kernel image was loaded low in RAM, move it to high.
  10. Set the A20 pin (a compatibility hack for ancient 8088 microprocessors).
  11. Setup a provisional Interrupt Descriptor Table (IDT) and a provisional Global Descriptor Table (GDT).
  12. Reset the floating-point unit (FPU).
  13. Reprogram the Programmable Interrupt Controllers (PIC).
  14. Switch from Real to Protected Mode.

startup_32():

  1. Initialize segmentation registers and a provisional stack.
  2. Clear all bits in the eflags register.
  3. Fill the area of uninitialized data with zeros.
  4. Invokes decompress_kernel() to decompress the kernel image.

startup_32() (same name, other function):

  1. Initialize final segmentation registers.
  2. Fill bss segment with zeros.
  3. Initialize provisional kernel Page Tables.
  4. Enable paging.
  5. Setup Kernel Mode stack for process 0.
  6. Again, clear all bits in the eflags register.
  7. Fill the IDT with null interrupt handlers.
  8. Initialize the first page frame with system parameters.
  9. Identify the model of the processor.
  10. Initialize registers with the addresses of the GDT and IDT.

start_kernel(): Nearly every kernel component gets initialized by this function, these are only a few.

  • Scheduler
  • Memory zones
  • Buddy system allocator
  • IDT
  • SoftIRQs
  • Date and Time
  • Slab allocator
  • Create process 1 (/sbin/init)

The complete "list" is available in the sources at linux/init/main.c

Init

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.

Type runlevel into the console, this gives you the current runlevel of your system.

Take a look into /etc/rcX.d/ (or /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.

share|improve this answer
    
LXR is a nice interface for reading the Linux kernel source. Nice list, though beware that a lot of it is very architecture-dependent (this is the PC version). –  Gilles Dec 28 '10 at 19:10
add comment
  • 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.
share|improve this answer
add comment

The boot loader jumps to the image entry point passing kernel command line (if any), and the kernel handles the rest.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.