Home >Operation and Maintenance >CentOS >What is the CentOS system startup process?

What is the CentOS system startup process?

WJ
WJOriginal
2020-06-03 15:29:491910browse

What is the CentOS system startup process?

#What is the CentOS system startup process?

When we press the power button, do we understand the secret behind the system? Here, I will take you to explore the secrets behind booting the Linux system.

What is the CentOS system startup process?

1. Power-on self-test

After the motherboard is powered on, the system first uses the POST program to check various internal devices. Check, if any error is found during the self-check, it will be handled in two situations: for serious faults (fatal faults), it will shut down. At this time, because various initialization operations have not been completed, no prompts or signals can be given; for non- If a serious fault occurs, a prompt or sound alarm signal will be given, waiting for the user to handle it.

2. BIOS startup boot phase

After the self-test is passed, each boot device is searched in order. The first device with a boot program is the boot target. equipment used. Generally, computers are entered into the BIOS by pressing the "F2" or "Del" key, where we can adjust the startup sequence of the hard disk.

After finding the first device with a boot program, the BIOS will find the MBR in the device and read the Bootloader

3.GRUP boot phase

At this time You can see our Centos system, but generally no operation is required, and the system will start automatically. In fact, we can also manually start the system ourselves

3.1 Manually start the system through the grub command line interface:

    grub> root (hd#,#)
  grub> kernel /vmlinuz-VERSION-RELEASE ro root=/dev/DEVICE 
  grub> initrd /initramfs-VERSION-RELEASE.img
   grub> boot

3.2 grub command line interface:

  e: 编辑模式,用于编辑菜单;
 c: 命令模式,交互式接口;
help: 获取帮助列表
help KEYWORD: 详细帮助信息
find (hd#,#)/PATH/TO/SOMEFILE:
root (hd#,#) 设定grup的根设备
kernel /PATH/TO/KERNEL_FILE: 设定本次启动时用到的内核文件;额外还可以添加许多内核支持使用的cmdline参数;
例如:init=/path/to/init, selinux=0
initrd /PATH/TO/INITRAMFS_FILE: 设定为选定的内核提供额外文件的ramdisk;
boot: 引导启动选定的内核;

3.3 Configuration file: /boot/grub/grub.conf

Configuration items:

default=#: 设定默认启动的菜单项;落单项(title)编号从0开始;
timeout=#:指定菜单项等待选项选择的时长;
splashimage=(hd#,#)/PATH/TO/XPM_PIC_FILE:指明菜单背景图片文件路径;
hiddenmenu:隐藏菜单;
password [--md5] STRING: 菜单编辑认证;
title TITLE:定义菜单项“标题”, 可出现多次;用来引导多个内核或者操作系统
    root (hd#,#):grub查找stage2及kernel文件所在设备分区;为grub的“根”; 
kernel /PATH/TO/VMLINUZ_FILE [PARAMETERS]:启动的内核
initrd /PATH/TO/INITRAMFS_FILE: 内核匹配的ramfs文件;
password [--md5] STRING: 启动选定的内核或操作系统时进行认证

4. Loading the kernel phase

The kernel will itself Initialization:

Detect all identifiable hardware devices;

Load hardware drivers; (The driver may be loaded with the help of ramdisk)

Mount in read-only mode Root file system;

Run the first application in user space: /sbin/init

5.init initialization phase

The kernel is loaded , will run the init program. After the init process starts up, the control of system startup is transferred to the init process

/sbin/init process is the parent process of all processes. When init starts up, it will first read the configuration file /etc/inittab, perform the following work:

1.执行系统初始化脚本(/etc/rc.d/rc.sysinit),对系统进行基本的配置,以读写方式挂载根文件系统及其它文件系统,到此系统基本算运行起来了,后面需要进行运行级别的确定及相应服务的启动;
2.确定启动后进入的运行级别;
3.执行/etc/rc.d/rc,该文件定义了服务启动的顺序是先K后S,而具体的每个运行级别的服务状态是放在/etc/rc.d/rcn.d(n=0~6)目录下,所有的文件均链接至/etc/init.d下的相应文件。
4.有关key sequence的设置
5.有关UPS的脚本定义
6.启动虚拟终端/sbin/mingetty 
7.在运行级别5上运行X

Configuration file: /etc/inittab

Each line defines an action and its corresponding process

id:runlevels:action:process 
id:一个任务的标识符;
runlevels:在哪些级别启动此任务;#,###,可以为空,表示所有级别;
action:在什么条件下启动此任务;
process:任务;(脚本或程序)
action:
wait:等待切换至此任务所在的级别时执行一次;
respawn:一旦此任务终止,就自动重新启动之;
initdefault:设定默认运行级别;此时,process省略;
sysinit:设定系统初始化方式,此处一般为指定/etc/rc.d/rc.sysinit脚本;

K*: The service to be stopped; K##*, priority, the smaller the number, the priority is to shut down; the dependent services are shut down first, and then the dependent ones are shut down;

S*: The service to be started; S##*, priority, the smaller the number, the priority to start; the dependent service is started first, and the dependent service is started last;

chkconfig command: control /etc/init .d/The startup or shutdown status of each service script at each level;

查看:chkconfig  --list   [name]
添加:chkconfig  --add  name
删除:chkconfig  --del  name

Modify the specified link type:

chkconfig  [--level  LEVELS]  name  <on|off|reset>
--level LEVELS:指定要控制的级别;默认为2345;
init命令:
级别切换:init #
级别查看:who -r

Related references: centOS Tutorial

The above is the detailed content of What is the CentOS system startup process?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn