Kernel boot process

Source: Internet
Author: User

System start-up process (1)

Pc:os (Linux)

Post (power on Self Test)-->bios (boot sequence) (decide where to start the operating system smoothly)--MBR (bootloader, 446bit)

-->kernel (file system, process management, memory management, network management, security features, drivers)-->initrd
--/sbin/init (Management of the user space process) [Start the System module, with the associated hardware information of the initialization file/etc/rc.d/rc.sysinit--> start the system the required services/ETC/RC.D/RC]

/etc/rc.d/ec.loacl can customize the script here, the service that can start on boot

The configuration files for these scripts are all placed in,/etc/sysconfig

System-Customized device and module files:/etc/modprobe.conf

Loading process:
1, the Power self-test, load the BIOS hardware information and self-testing, and according to the settings to obtain the first bootable device;
2. Read and hold the boot loader (i.e., grup,spfdisk, etc.) of the MBR in the first boot device.
3, according to boot loader settings load Kernel,kernel will start to detect hardware and load drivers
4, after the hardware driver succeeds, the kernel will invoke the INIT process actively, and INIT will get the information such as Run-level.
5. Init executes the/etc/rc.d/rc.sysinit file to prepare the operating environment for software execution (e.g. network, time zone, etc.)
6, init execution run-revel of the various services start
7. Init Execute/etc/rc.d/rc.local File
8, init execution Terminal simulation program Mingetty to start the login process, and finally the user login

RunLevel: Different services started
Operating level: 0-6
0:halt shut down the machine
1:single user mode single-username, directly into the administrator, without password (Maintenance mode) 1 S S singer
2:multi user mode, no NFS file system multiuser
3:multi user mode, multiuser command mode
4:reseved retention Level
5:multi user Mode multiuser interface mode
6: Restart

Run-level configuration file/etc/inittab

  Detailed startup process
    bootloader (belongs to MBR)
           linux    lilo:linux LOader
                    GRUB:
                    STAGEL:MBR
                    stagel1.5:
                    stagel:/boot/grub/

  grub  profile
greb.conf
 default=0     Set the number of the default start title, starting with 0
timeout=5      waits for the user to select the timeout length, the unit is wonderful
Splashimage= (hd0,0)/grub/splash.xpm.gz   Grub background Image
hiddenmenu    hidden menu
Password Clear text
password --md5  MD5 format encrypted             command line grub-md5-crypt  can directly generate MD5 password
Title CentOS 6 (2.6.32-504. el6.x86_64)      kernel title or operating system name, strings can be freely modified by
        root (hd0 , 0)     kernel files on the device, for grub, all types of hard drives are HD: represents the number of disks, and the last 0 indicates the partition of the corresponding disk
         kernel/vmlinuz-2.6.32-504.el6.x86_64 ro sfont=
        initrd/ Initramfs-2.6.32-504.el6.x86_64.img

To view the run level:
RunLevel Who-r

To view the kernel:
UNAME-R Display Kernel version number

Install Grub Stagel:
#grub
Grub >root (hd0,0)
Grub >set (hd0)
Install grub the second way:
# Grub-install--root-directory=/
Kernel The process of initialization:
1: Device detection
2: Driver initialization (load driver module from INITRD file)
3: Mount the root file system as read-only
4: Load the first process init (pid:1)


    /sbin/init:   Read files (/etc/inittab)
          upstart
        
          ID: identifier
         runlevels: at which level to run;
          action: Under what circumstances this line is executed;
         Process: to run processes;
     
         si:sysinit (System initialization)
   
          initdefault: Set default Run Level
           Sysinit: System initialization
           wait: Wait for level switch to complete
         

Tasks completed by/etc/rc.d/sysinit:
1. Activate Udev and SELinux;
2/According to the/etc/sysctl.conf file, to set the kernel parameters;
3, set the clock clock;
4, loading keyboard mapping;
5: Enable swap partition;
6: Set host name;
7: Root file system detection, and read-write override Mount
8: Activating Rsid and LVM devices
9: Enable disk quotas;
10: According to/etc/fstab, check and mount other file system;
11: Clean up expired lock and PID files;




The style of the kernel design:
Single Core: Make all the functions more than one kernel, Linux, only lightweight process (thread) support
Core: KO (Kernel object)

Micro-core: window, multi-threading support


Chroot:chroot/path/to


Core:/boot/vmlinuz-version
Kernel module (KO):/lib/modules/version/
Kernel design:
Single Core Linux modular design the kernel is small. Basic function Loading module


Modular design of micro-core

Loading module:
Indmod
www.kernel.org
User space access, how to monitor the kernel:
/proc,/sys

Pseudo file System
/proc/sys: Files in this directory can be read and written,
/sys: Some files can be written

To set kernel parameter values:
echo VALUE >/proc/sys/...
Sysctl-w kernel.hostname=

Kernel parameter script:/etc/sysctl.conf


Kernel module management;
Lists which modules are loaded by the kernel Command:lsmod
Management module: modprobe mod_name: Loading a module
Modprobe-r Mod_name Uninstalling a module

View specific information about the module Modinfo com_name

Insmod/path/to/mod-name_file load module, be sure to specify the path of the module

Remod mod_name Removal of a module


Depmod/ptah/to/modlies_str depends on the relationship


In addition to the core functionality of the kernel, most features will have three options when compiling:
1. Do not use this function
2. Compile into kernel module
3. Compile into kernel

How to manually compile the kernel:

View Kernel version: Uname-r


Kernel boot process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.