Linux main components: kernel+rootfs+ library + Program
Kernel (kernel): Process management, memory management, network management, drivers, file systems, security features, etc.
Rootfs (Root file System): glibc (library file), etc.
Libraries: function sets, functions, calling interfaces
Procedure: Procedure call, no return value
Functions: Function call, with return value
Kernel design Genre:
Single Core design: All functions are integrated into the same program. For example: Linux
Microkernel Design: Each function is implemented with a single subsystem. Example: Windows,solaris
Linux kernel Features:
Support modularity:. Ko
Dynamic loading and unloading of support modules
Linux Kernel components:
Core file:/boot/vmlinux-version-release
RAMDisk: Secondary mount HDD Drive
CENTOS5: Analog to Hard drive/boot/initrd-version-resease.img
CENTOS6: Analog to File system/boot/Initramfs-version-resease.img
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7A/26/wKiom1ajecXjX4z0AAA1-nlNfGY259.png "title=" 1.png " alt= "Wkiom1ajecxjx4z0aaa1-nlnfgy259.png"/>
Module file:/lib/modules/version-release/
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7A/25/wKioL1aje5yD57QJAAA7h_Sq4qg670.png "title=" 2.png " alt= "Wkiol1aje5yd57qjaaa7h_sq4qg670.png"/>
CentOS 5 System Startup process
POST--Bootsequence (BIOS)--bootloader (MBR)--Kernel (ramdisk)--ROOTFS (read-only)--/sbin/init- Etc/inittab)--Set the default run level (Id:3:initdefault:)--run the system initialization script, complete the system initialization (Si::sysinit:/etc/rc.d/rc.sysinit --Shut down and start the corresponding level write the service that needs to be shut down (L#:#:WAIT:/ETC/RC.D/RC #)--Set the login terminal (Tty1:2345:respawn:/usr/sbin/mingetty tty1)
(1) POST: Power-on self-test
(2) BIOS: Basic Input and Output System
boot Sequence: In order to find the boot device, the first device with a boot program is the device used for this start;
(3) bootloder: Boot loader
Linux contains two Bootloder, Lilo (Linux LOader) and GRUB (Grand Uniform Bootloader)
Features: Provides a menu that allows the user to select a system to boot or a different kernel version, load the selected kernel into a specific space in memory, unzip, expand, and transfer control of the system to the kernel
(4) kernel: ( must be read-only when loading the root and re-hung in the system initialization script/etc/rc.d/rc.sysinit )
Self-initialization:
detect all hardware devices that can be identified
Load the hardware driver (it is possible to load the driver with RAMDisk)
mount the root file system as read-only (Rootfs read-only)
The first application running user space:/sbin/init
Types of init programs:
sysv:init (used in CentOS5, configuration file:/etc/inittab)
upstart:init (used in CentOS6 and compatible with CENTOS5, configuration file:/etc/inittab,/etc/init/*.conf)
systemd:systemd (centos7 configuration file:/usr/lib/systemd/system,/etc/systemd/system)
RAMDisk Type:
RAMDISK:INITRD (CENTOS5 system is generated by MKINITRD after installation
Ramfs:initramfs (generated by Dracut after CENTOS6 system is installed)
(5) /sbin/init
Operating level: Set for application purposes such as operation or maintenance of the system
0-6:
# 0-halt (do not set Initdefault to this)
# 1-single User mode
# 2-multiuser, without NFS (the same as 3, if you don't have networking)
# 3-full Multiuser mode
# 4-unused
# 5-x11
# 6-reboot (do not set Initdefault to this)
0: Turn off the machine
1: Single user mode (root, no login required), one, maintenance level
2: Multi-user mode: Network function is started, but NFS is not started, maintenance mode
3: Multi-user mode: Normal mode, default to Text interface
4: Reserved level: Available with 3 levels
5: Multi-user mode: Normal mode: Graphical interface
6: Restart
Toggle Level: Init #
View level: Runlevel,who-r
Configuration file:/etc/inittab
Id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit
L0:0:WAIT:/ETC/RC.D/RC 0
L1:1:WAIT:/ETC/RC.D/RC 1
...
L6:6:WAIT:/ETC/RC.D/RC 6
Each row defines an action and the process that corresponds to it
id:runlevel:action:process
Action:
Wait: Switch to this level to run once
Respawn: This process terminates and the restart is
Initdefault: Set default Run Level: process omitted
Sysinit: Sets the system initialization mode, where the specified/etc/rc.d/rc.sysinit is typically
...
NOTE:RC 0--> means reading the/etc/rc.d/rc0.d/[k*| S*]
k*:k##*
s*:s##* linked files, source files located in/etc/rc.d/init.d/
# #: The smaller the number, the higher the priority, depending on the service dependency
terminate K start service in order, start the S start service
for SRV in/etc/rc.d/rc0.d/k*;d o
$srv stop
Done
For SRV in/etc/rc.d/rc0.d/s*;d o
$srv Start
Done
Chkconfig: Managing Services
--list: View all services on/off status at all levels
--add Name: Add a Service script SysV type placed in/ETC/RC.D/INIT.D (/ETC/INIT.D)
--del Name: Delete
--level # # # # NAME On/off/reset: Modify the link type at the specified level
--level: omitted as 2345
7 levels of S or K depending on the Chkconfig line in the service script
#! /bin/bash
#
#chkconfig: LLL nn nn
LLL: Which level is S (0-6)
The order in the Nn:s
The order in the Nn:k
Note: At normal level, a service s99local that was last started is not a service script that is linked to/ETC/RC.D/INIT.D, but instead points to the/etc/rc.d/rv/local script; therefore, it is inconvenient or not required to be written as a service script placed in the/etc/rc.d/ INIT.D directory, and a command to automatically run the boot, can be placed directly in the/etc/rc.d/rc.local file
Tty1:2345:respawn:/usr/sbin/mingetty tty1
Tty2:2345:respawn:/usr/sbin/mingetty Tty2
Tty3:2345:respawn:/usr/sbin/mingetty Tty3
Tty4:2345:respawn:/usr/sbin/mingetty Tty4
Tty5:2345:respawn:/usr/sbin/mingetty Tty5
Tty6:2345:respawn:/usr/sbin/mingetty Tty6
Mingetty will automatically invoke the login program
Tips
/etc/rc.d/rc.sysinit: System Initialization script
(1) Set host name
(2) Setting welcome information
(3) Activate Udev and SELinux
(4) Mount the file system defined in the/etc/fstab file
(5) Detect the root file system and re-mount the root filesystem in read/write mode (kernel mount is read-only and re-mounted here)
(6) Setting the system clock
(7) Activate swap device
(8) Set kernel parameters according to/etc/sysctl.conf file
(9) activating LVM and software RAID devices
(10) Loading drivers for additional devices
(11) Cleaning operation
The system boot process for CentOS 6 is roughly the same as 5, but its init program is upstart and its configuration file is/etc/inittab,/etc/init/*.conf, not a single/etc/inittab file.
[email protected] init]# LL
Total 68
-rw-r--r--. 1 root root 412 Apr 9 control-alt-delete.conf
-rw-r--r--. 1 root root init-system-dbus.conf
-rw-r--r--. 1 root root 463 Apr 9 kexec-disable.conf
-rw-r--r--. 1 root root 560 Apr 9 plymouth-shutdown.conf
-rw-r--r--. 1 root root 357 APR 9 prefdm.conf
-rw-r--r--. 1 root root 505 APR 9 quit-plymouth.conf
-rw-r--r--. 1 root root 417 Apr 9 rc.conf
-rw-r--r--. 1 root root 1046 Apr 9 rcs.conf
-rw-r--r--. 1 root root 430 APR 9 rcs-emergency.conf
-rw-r--r--. 1 root root 725 Apr 9 rcs-sulogin.conf
-rw-r--r--. 1 root root 2915 Nov readahead-collector.conf
-rw-r--r--. 1 root root 1559 Nov readahead.conf
-rw-r--r--. 1 root root 726 Nov readahead-disable-services.conf
-rw-r--r--. 1 root root 1302 Apr 9 serial.conf
-rw-r--r--. 1 root root 791 Apr 9 splash-manager.conf
-rw-r--r--. 1 root root 473 Apr 9 start-ttys.conf
-rw-r--r--. 1 root root 335 Apr 9 tty.conf
[Email protected] init]#
This article from the "Smart Young Planck" blog, declined to reprint!
CentOS 5 and 6 start-up process