Linux-based CentOS system start-up process

Source: Internet
Author: User
Tags network function

CentOS system Start-up process


Components of the Linux system: Kernel + Root file system

Kernel: Process management, memory management, network protocol stack, file system, drivers, security features

Ipc:inter Process Communication

Message Queuing, Semerphor, SHM

Socket

The system environment in operation can be divided into two tiers: kernel space, user space

User space: Application (process or thread)

Kernel Space: Kernel code (System call)

Kernel design Genre:

Single Core design: Integrate all functions into the same program;

Linux

Microkernel Design: Each function is implemented using a separate subsystem;

Windows, Solaris

Linux kernel Features:

Support modularity:. KO (Kernel object)

Supports dynamic loading or unloading of modules during runtime;

Part:

Core file:/boot/vmlinuz-version-release

RAMDisk

CentOS 5:/boot/initrd-version-release.img

CentOS 6,7:/boot/initramfs-version-release.img

Module file:/lib/modules/version-release

The start-up process for the CentOS system:

Post: Power-on self-test;

Rom:cmos

Bios:basic Input and Output System

Rom+ram

Boot Sequence:

In order to find the boot device, the first device with a boot program is the device to be used for this launch;

Bootloader: Boot loader, program;

Windows:ntloader

Linux:

Lilo:liinux LOader

Grub:grand Uniform Bootloader

GRUB 0.x:grub Legacy

GRUB 1.X:GRUB2

Function: Provides a menu that allows the user to select the system to be launched or a different kernel version, to load the user-selected kernel into a specific space in RAM, unzip, expand, and then transfer control of the system to the kernel;

Mbr:master Boot Record

512bytes:

446bytes:bootloader

64bytes:fat

2bytes:55aa

Grub:

bootloader:1st Stage

Partition:filesystem driver, 1.5 stage

Partition:/boot/grub, 2nd Stage

Note: uefi,gpt

Kernel:

Self-initialization:

Detect all the hardware devices that can be identified;

Load the hardware driver; (possibly with ramdisk load driver)

Mount the root file system in read-only mode;

The first application running user space:/sbin/init

Types of init programs:

CentOS 5-:SYSV Init

Configuration file:/etc/inittab

CentOS 6:upstart

Configuration file:/etc/inittab

/etc/init/*.conf

CentOS 7:SYSTEMD

Configuration files:/usr/lib/systemd/system/,/etc/systemd/system/

RAMDisk

One of the features of the Linux kernel: use buffering and caching to speed up file access on disk;

RAMDisk-Ramfs

CentOS 5:INITRD

Tool Program: MKINITRD

CentOS 6,7:initramfs

Tool Program: Dracut, MKINITRD

System initialization process (Kernel level): POST--Bootsequence (BIOS)--BootLoader (MBR)--Kernel (RAMDisk)--Rootfs (readonly)-- >/sbin/init ()

/sbin/init:

CentOS 5:SYSV Init

Operating level: a mechanism set up for the purpose of operating or maintaining the system;

0-6:7 levels;

0: Shutdown, shutdown

1: Single user mode, root user, no authentication, maintenance mode;

2, multi-user mode (multi user), will start the network function, but will not start NFS; maintenance mode;

3. Multi-user mode (Mutli user), full function mode, text interface;

4, Reserved level: Currently no special use purposes, but the habit of using the same 3-level function;

5, multi-user mode (multi user), full function mode, graphical interface;

6, restart, reboot

Default Level: 3, 5

Level switch: Init #

Level view:

Who-r

RunLevel

Configuration file:/etc/inittab

Each row defines an action and the process that corresponds to it

Id:runlevels:action:process

ID: The identifier of a task;

Runlevels: The level at which this task is started; #,### can also be empty, indicating all levels;

Action: Under what conditions to start this task;

Process: task;

Action

Wait: Executes once while waiting to switch to the level at which the task is located;

Respawn: Once this task is terminated, it will be restarted automatically;

Initdefault: Sets the default RunLevel, at which time the process is omitted;

Sysinit: Set the system initialization mode, here is generally designated/etc/rc.d/rc.sysinit script;

For example:

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

means to start or close the service that the service script under the/etc/rc.d/rc3.d/directory controls;

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

S*: The service to be started, s##*, priority, the smaller the number, the more priority to start, the dependent service starts first, and the dependent service starts;

RC script: Accepts a run-level number as a parameter;

Script framework:

for SRV in/etc/rc.d/rc#.d/k*; Do

$srv stop

Done

for SRV in/etc/rc.d/rc#.d/s*; Do

$srv start

Done

/etc/init.d/* (/etc/rc.d/init.d/*) Script execution method:

#/etc/init.d/srv_script {Start|stop|restart|status}

# service Srv_script {start|stop|restart|status}

Chkconfig command: Control/etc/init.d/the startup or shutdown status of each service script at all levels;

View: Chkconfig--list [Name]

Added: Chkconfig--add name

One of the script definition formats for the service that can be added:

#!/bin/bash

#

# chkconfig:lll nn nn

# Description:

Delete: Chkconfig--del name

To modify the specified link type:

Chkconfig [--level levels] name <on|off|reset>

--level levels: Specifies the level to be controlled; default is 2345;

Note: At normal level, a service s99local that was last started is not linked to a script under/ETC/INIT.D, but is linked to/etc/rc.d/rc.local (/etc/ rc.local) script, so that a program that is inconvenient or does not need to be written as a service script is placed in this script file directly when it is expected to run automatically.

Tty1:2345:respawn:/usr/sbin/mingetty tty1

... ...

Tty6:2345:respawn:/usr/sbin/mingetty Tty6

(1) Mingetty will invoke the login program;

(2) Open the virtual terminal program in addition to Mingetty, there are such as Getty, etc.;

System Initialization script:/etc/rc.d/rc.sysinit

(1) Set the host name;

(2) Set welcome information;

(3) Activate Udev and SELinux;

(4) Mount all file systems defined in the/etc/fstab file;

(5) Detecting the root file system and re-mounting the root file system in read-write mode;

(6) Set the system clock;

(7) Set kernel parameters according to/etc/sysctl.conf file;

(8) activating LVM and soft raid devices;

(9) Activate swap device;

(10) Loading the drivers for additional devices;

(11) Cleaning operation;

Summary (User space Start-up process):/sbin/init (/etc/inittab)

Set the default run level-run the system initialization script, complete the system initialization--close the service that needs to be stopped at the corresponding level, start the service that needs to be turned on at the corresponding level, and set the login terminal [--> to start the graphics terminal]

CentOS 6:

Init program: Upstart, but still for/sbin/init, its configuration file:

/etc/init/*.conf,/etc/inittab (for defining the default RunLevel only)

Note: *.conf is a upstart-style configuration file;

Rcs.conf

Rc.conf

Start-ttys.conf

CentOS 7:

Init program: systemd, config file:/usr/lib/systemd/system/*,/etc/systemd/system/*

Fully compatible with the SYSV scripting mechanism; Therefore, service commands are still available; however, it is recommended to use the SYSTEMCTL command to control services;

# systemctl {start|stop|restart|status} Name[.service]

Blog assignment: CentOS system start-up process;


Linux-based CentOS system start-up process

Related Article

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.