Linux getting started Tutorial: Linux boot process analysis
Linux boot process analysis
Introduction
The boot process is divided into the following six steps: BIOS, MBR, GRUB, Kernel, Init, RunLevel, RunDefinition
BIOS
Press the power switch to start BIOS loading and execute MBR (Master Boot Record)
BIOS indicates the Basic Input/Output System,
Load and execute a boot loader that looks for a boot program on a floppy disk, CD-ROM, or hard disk. You can
When the system starts, press the keyboard (usually F12 or F2, But it varies with the system) to modify the startup sequence.
Once the boot program is detected and loaded into the memory, the BIOS will hand over control to it
MBR
MBR indicates the Master Boot Record)
Used to load and execute GRUB
GRUB
GRUB is a multi-Boot manager (GRand uniied Bootloader)
Run/etc/grub. conf to load the kernel Image
Vim/etc/grub. conf
Default = 0
Timeout = 5
Splashimage = (hd0, 0)/grub/splash.xpm.gz
Hiddenmenu
Title CentOS 6 (2.6.32-504. el6.x86 _ 64)
Root (hd0, 0)
Kernel/vmlinuz-2.6.32-504.el6.x86_64 ro root =/dev/mapper/vg_ddz-lv_root kernel rd_NO_MD kernel = vg_ddz/lv_root crashkernel = 128 m lang = zh_CN.UTF-8 kernel = vg_ddz/lv_swap KEYBOARDTYPE = pc KEYTABLE = us kernel rhgb quiet
Initrd/initramfs-2.6.32-504.el6.x86_64.img
Kernel
Execute the first process/sbin/init in the kernel. The process number is 1, which is the parent process of all other processes.
Initrd indicates Initial RAM Disk
Initrd is used as a temporary root directory by the kernel until the kernel is started and the real root directory is mounted successfully.
It also includes some compiled drivers that help it access hard disks and other hardware.
Init
Run the/etc/inittab to determine the startup level.
Vim/etc/intttab
# Default runlevel. The runlevels used are:
#0-halt (Do NOT set initdefault to this)
#1-Single user mode
#2-Multiuser, without NFS (The same as 3, if you do not have networking)
#3-Full multiuser mode (Terminal mode)
#4-unused
#5-X11 (graphical user interface)
#6-reboot (Do NOT set initdefault to this)
#
Id: 5: initdefault: Run/etc/rc. d/rc. sysinit to start the system process, such as NetWork
RunLevel
Execute a series of system services at the startup level
The directory corresponding to the startup level is as follows:
Ll/etc/rc. d/
Drwxr-xr-x. 2 root 4096 November 29 09:49 rc0.d
Drwxr-xr-x. 2 root 4096 November 29 09:49 rc1.d
Drwxr-xr-x. 2 root 4096 March 10 17:18 rc2.d
Drwxr-xr-x. 2 root 4096 March 10 17:18 rc3.d
Drwxr-xr-x. 2 root 4096 March 10 17:18 rc4.d
Drwxr-xr-x. 2 root 4096 March 10 17:18 rc5.d
Drwxr-xr-x. 2 root 4096 November 29 09:49 rc6.d
RunDefinition
Finally, run/etc/rc. d/rc. local to run the Custom Service.
Vim/etc/rc. d/rc. local
1 #! /Bin/sh
2 #
3 # This script will be executed * after * all the other init scripts.
4 # You can put your own initialization stuff in here if you don't
5 # want to do the full Sys V style init stuff.
6
7 touch/var/lock/subsys/local
8 if test-f/sys/kernel/mm/transparent_hugepage/enabled; then
9 echo never>/sys/kernel/mm/transparent_hugepage/enabled
10 fi
11 if test-f/sys/kernel/mm/transparent_hugepage/defrag; then
12 echo never>/sys/kernel/mm/transparent_hugepage/defrag
13 fi
14
15/bin/bash/usr/local/apps/kylin/bin/kylin. sh start
Among them, 15th are custom startup scripts.
Final
Enter the logon page
This article permanently updates link: https://www.bkjia.com/Linux/2018-03/151323.htm