Linux boot process

Source: Internet
Author: User
Tags delete key network function

Linux system boot process diagram
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/4C/74/wKiom1Q93TuDN2OaAAL5Tg2FUyk964.jpg "title=" Linux boot process. png "alt=" wkiom1q93tudn2oaaal5tg2fuyk964.jpg "/>Post:
After the server is powered on, the CPU, memory, video card, keyboard and other devices will be initially probed according to the setting of the motherboard BIOS, and the control will be controlled by the hard drive after successful detection.
MBR boot (446):
When the drive is under control, the system will find the partition of the system boot file based on the MBR partition table, or call the boot menu directly based on the boot information in the MBR record.
Grub Menu:
Grub is a multi-system boot menu, and if a dual system is installed, you can choose to enter that operating system here, then load the kernel file and transfer control to the kernel.
load the Linux kernel:
After the kernel takes control, it will initialize the drive and mount the root filesystem in read-only mode, loading the first process init (pid:1)
initialization of the init process:
Init process is responsible for completing a series of system initialization process: Configuration file/etc/inittab, according to the configuration content first Execute initialization script file/etc/rc.d/rc.sysinit, and through the script file/etc/rc.d/rc control should start those programs and services, Finally run terminal program/sbin/mingetty, waiting for the user to log in.


Grub Introduction
Grub is divided into three stages
Stage one: Installed in MBR, in order to guide the second stage
Phase 1.5: Booting a common file system
Stage Two: booting the operating system


Grub configuration file is located in/etc/grub

Default=0//Set the number of the default boot title timeout=5//wait for user to select the timeout often splashimage= (hd0,0)/boot/grub/splash.xpm.gz//Specify the grub background picture hi  Ddenmenu//Hide menu Password Password//Add password Password--md5 $1$LA77X1$TDM1FD2ADJRF7VDUFZQLS0//Set Encryption password title Red Hat Enterprise Linux Server (2.6.18-92.EL5)///kernel title or operating system title, you can freely modify the root (hd0,0)///kernel files on the device: for grub, all types of hard drives are HD; The first 0 indicates the number of disks; The last 0 indicates the corresponding disk Partition Kernel/boot/vmlinuz-2.6.18-92.el5 ro root=label=/rhgb quiet//kernel file path, and parameters passed to the kernel initrd/boot/initrd-2.6 .18-92.el5.img//ramdisk File path


Generate a password string for grub encryption, put the password string into the grub file to access other people to view the grub password

[Email protected] sbin]# grub-md5-crypt password:retype Password: $1$la77x1$tdm1fd2adjrf7vdufzqls0

If grub is damaged or is accidentally deleted, you will need to reinstall GRUB
Install Grub First Stage
Grub command to open grub
Root (hd0,0) specifies the kernel disk
Setup (hd0) specifies the installation disk

The second way to install grub
Grub-install--root-directory=/The parent directory of the path where the kernel is located (does not need to enter the boot directory, will automatically find) the specified hard disk

For example, you need to install grub under/test/boot
Grub-install--root-directory=/test//dev/sdb

If grub is removed and cannot enter the operating system
Grub> Find//If there are multiple disks you can use the Find probe root where
Grub>root (hd#,n)//Specify the disk on which the root resides
Grub>kernet/path/to/kernel_file//Specify Kernel file path
Grub>initrd/path/to/initrd_file//Specify INITRD file path
Grub>boot//Boot system
After booting the system to create a grub file, the next time you start the system will not need to manually lose


Init Introduction
Init defines the
Run level
0: Turn off the machine
1: Single user mode, login directly to admin without entering password
2: Multi-user mode, network function, disable NFS file system
3: Multi-user mode for character interface, most server hosts run at this level
4: Reserved, level
5: Graphical multi-user, terminal mode
6: Turn off the machine
When the INIT program runs, the corresponding scripts and programs in the system are started in the following configuration, as specified in the/etc/inittab file.
In the/etc/inittab file, no line is considered a valid configuration record except for comment information and blank lines that begin with the # sign. Use ":" to split between four fields in each configuration record.
The format is as follows:
Id:runlevels:action:process
ID:identifier, which requires a unique
runlevels:At which level to run this line;
Action:Under what circumstances the line is executed;
Process:To run the program; It can be a specific command, a scripting program, etc.

Action field available parameter description
Initdefault:Set the operating level that the system enters by default after initialization
Sysinit:Set the operation script for system initialization
Wait:The init process waits for the line configuration to complete after the script operation has completed, and then continues to perform other operations
Ctrlaltdel:Set the action when the user presses the Ctrl+alt+delete key combination
Powerfail:Set what action to take when the system receives a power-off signal (using a UPS)
Powerokwait:Set what action to take when the system receives a power-back signal
respawn:Restart the process once the corresponding process for the line configuration is terminated


rc.sysinit script File
Rc.sysinit is a system initialization script that is called by the Init process, and is located in the/etc/rc.d/directory, where the following actions can be done by using the secondary script
Tasks completed by/etc/rc.d/rc.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 the swap partition;
6, set the host name;
7, the root file system detection, and read-write mode to re-mount;
8. Activate RAID and LVM devices;
9, enable disk quotas;
10, according to/etc/fstab, check and mount other file system;
11, clean up the expired lock and PID file;

RC script File
The RC script is also called by the Init process and the file is located in/ETC/RC.D/RC. The RC script enters the appropriate system level by loading and terminating different system services, respectively, by using different level parameters.

[Email protected] ~]# Cat/etc/inittab | grep "RC.D/RC" SI::SYSINIT:/ETC/RC.D/RC.SYSINITL0:0:WAIT:/ETC/RC.D/RC 0l1:1:wait:/etc/rc.d/rc 1l2:2:wait:/etc/rc.d /RC 2L3:3:WAIT:/ETC/RC.D/RC 3L4:4:WAIT:/ETC/RC.D/RC 4L5:5:WAIT:/ETC/RC.D/RC 5L6:6:WAIT:/ETC/RC.D/RC 6

/ETC/RC.D/RC 0 to/ETC/RC.D/RC 6 directory, save some special symbolic link files, rc script calls the corresponding service control program according to these linked files, to start or terminate the operation of the related service program.
The files under the/ETC/RC.D/RCX.D directory have the following rules.
The file name starts with K or S, the middle is the number ordinal, and finally the service script name in the system;
For the RC script, when the name of the linked file starts with S, the corresponding service is started, and the corresponding service is terminated at the beginning of K, and the median number indicates the order of execution at startup or termination.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/4C/75/wKioL1Q93QuiaDlhAAMP0IR93EU150.jpg "title=" Rc.d.png "alt=" Wkiol1q93quiadlhaamp0ir93eu150.jpg "/>






This article from "Plum blossom fragrance from bitter cold" blog, please be sure to keep this source http://wangjunkang.blog.51cto.com/8809812/1564207

Linux boot 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.