Learn more about the Linux operating system boot process

Source: Internet
Author: User

Linux boot process of the operating system: Post, MBR Guide, Grub menu, loading Linux Kernel, Init process initialization.

1. Post, check the hardware and give control to the local hard drive according to the boot order

2.mbr Boot, transfer control to boot partition or boot menu according to the master boot record of the hard drive

3.grub menu, the Start menu gives the user the option to enter a different operating system (e.g. Windows ) interface. The default entry to Linux transfers system control to the kernel.

4. Load linux linux system.

5.init initialization of the process, the kernel first /sbin/init This process corresponds to the PID number is always 1 . The program is loaded into memory to run. the init process is responsible for completing the system initialization process:

(1). reading configuration Files /etc/inittab

(2). determine the boot level based on the profile, and then execute /etc/rc.d/rc.sysinit

(3). through the script file /ETC/RC.D/RC N control which programs and services are started at different startup levels

(4). finally the system will run /sbin/mingetty command to open a new terminal program

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/7D/31/wKioL1biMPqRsRUhAADtuVsefrQ773.png "title=" 1.png " alt= "Wkiol1bimpqrsruhaadtuvsefrq773.png"/>

[Email protected] ~]# Cat/etc/inittab

# Inittab This file describes how the INIT processshould set up

# The system in a certainrun-level.

# Author:miquel van Smoorenburg,<[email protected]>

# Modified for RHS Linux by Marc Ewingand Donnie Barnes

# Default RunLevel. The runlevels used by RHS is:

# 0-halt (do not set Initdefault to this)------------ Shutdown Status

# 1-single User mode----------------- Single-user mode

# 2-multiuser, without NFS (the same as 3, if you don't have networking)------------ character Interface Multi-user mode (network not supported)

# 3-full multiuser mode---------------- full Multi-user mode for character interface

# 4-unused------------------ not used

# 5-x11-------------------- graphical Multi-user mode

# 6-reboot (do not set Initdefault to this)--------------- Restart status

#

Id:5: Initdefault : ----------------- default run level entered after initializing the system

# systeminitialization.

si:: Sysinit :/etc/rc.d/rc.sysinit--------------- System-initiated Action script (start level is empty and all levels)

l0:0: wait :/etc/rc.d/rc0--------------- Init The process waits for all scripts for that content to finish before continuing with the other

L1:1:wait:/etc/rc.d/rc1

L2:2:wait:/etc/rc.d/rc2

L3:3:wait:/etc/rc.d/rc3

L4:4:wait:/etc/rc.d/rc4

L5:5:WAIT:/ETC/RC.D/RC5--------------- startup scripts for each service that the content needs to perform for that boot level

L6:6:wait:/etc/rc.d/rc6

# Trapctrl-alt-delete

CA:: Ctrlaltdel :/sbin/shutdown-t3-r now

# when our UPS Tellsus Power had failed, assume we have a few minutes

# of Power left. Schedule a shutdown for 2 minutes.

# This does, ofcourse, assume you have Powerd installed and your

# UPS connected andworking correctly.

PF:: Powerfail :/sbin/shutdown-f-H +2 "Power Failure; System Shuttingdown "

# If Power wasrestored before the shutdown kicked in, cancel it.

pr:12345: powerokwait :/sbin/shutdown-c "Power restored; Shutdowncancelled "

# Run Gettys Instandard runlevels

1:2345: respawn :/sbin/mingettytty1--------------- re-open a terminal in the form of rebirth

2:2345:respawn:/sbin/mingettytty2

3:2345:respawn:/sbin/mingettytty3

4:2345:respawn:/sbin/mingettytty4

5:2345:respawn:/sbin/mingettytty5

6:2345:respawn:/sbin/mingettytty6

# Run XDm in Runlevel5

X:5:respawn:/etc/x11/prefdm–nodaemon

------------------------------------------------------------------------------------------------------------

The above is the comment information that begins with the content in the/etc/inittab file . The remaining four fields in each row of records represent:

X:5: respawn:/etc/x11/prefdm–nodaemon

Id:runlevels:action:process

|                          |                          | |

Mark   Run Level    action Type Program Scripts

#init q------------- can re-read Inittab configuration if file changes

#cat/etc/rc.d/rc.sysinit------------ System initialization script, complete a series of initialization tasks including setting up network, hostname, loading file system, setting clock, detecting file system, etc.

#vim/etc/rc.d/rc.local------------Executes the script after a startup script of level 2,3,4,5 executes. You can manually add some commands to a custom command that executes as soon as the system starts. For example:

#echo '/sbin/hwclock--hctosys ' >>/etc/rc.d/rc.local-------- update their system time based on the BIOS time of the real machine

System Service Control:

The control scripts for each service are stored in the/etc/rc.d/init.d/ directory

The service program can be controlled in two ways

method 1:#service the service name control type

method 2:/etc/init.d/the service name control type

control type is divided into:stop(start)|stop(stop)|restart(restart)|reload(Heavy)|status (View status)

Example:#/etc/init.d/sshd start----------- Open the remote SSH protocol

both of these methods cannot be applied after the next boot of the system. where Reload(overloads) can update the configuration of the service without stopping the service.

To switch the run level:

#runlevel-------------- View the last run level and the current RunLevel

#init 3-------------- switch The run level to the character interface where level 6 restarts level 0 for shutdown

Optimize boot auto-loading process:

The character interface can be optimized in two ways

method 1:#ntsysv--------------- Open a graphical session interface under the character interface to select the startup service that the current runlevel can set. If you want to make adjustments to other run levels, you can add options and parameters. For example:

#ntsysv –level------------ set the startup service with a start level of 3 and 5 with an asterisk for boot without an asterisk, select whether to enable by using the SPACEBAR to not start.

method 2:#chkconfig –list------------ to see how the service starts at each boot level

#chkconfig –list sshd------- to view the startup situation of the SSHD service at different boot levels

#chkconfig –level 345 sshd on/off--------- used to control whether the Sshd service is enabled in the 345 boot level


This article is from the "Brother to share" blog, please be sure to keep this source http://renzhiyuan.blog.51cto.com/10433137/1749849

Learn more about the Linux operating system boot process

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.