Root file system startup Analysis

Source: Internet
Author: User
Tags sigint signal
Root file system startup analysis-general Linux technology-Linux programming and kernel information. The following is a detailed description. Creator
Sz111@126.com

Generally, the system starts/sbin/init first, but you can also specify init = by using the startup parameter. For example, my system is developed as init =/linuxrc, because the file system uses busybox, and linuxrc. It is also a file pointing to busybox, but it is not sure which command it points. However, it may be/sbin/init.

The main task of the init process is to create a process according to the information provided by the inittab file. Because all the processes initialized by the system are created by init, The init process is also called the system initialization process.

For example, my inittab:
: Sysinit:/etc/init. d/rcS
: Respawn:-/bin/login
: Restart:/sbin/init

: Ctrlaltdel:/bin/reboot
: Shutdown:/bin/umount-a-r
: Shutdown:/sbin/swapoff-

The inittab format is as follows:
Id: rstate: action: process

1. The id field is a string of up to four characters, used to uniquely identify a table item.

2. the rstate (run state) field defines the running level of the record item when it is called. The rstate can be composed of one or more running levels, or it can be empty. If it is null, it indicates the running level 0 ~ 6. When the init is requested to change the running level, processes that do not include the new running level in the rstate field will receive the SIGTERM warning signal and finally be killed; only commands started by a, B, and c (a, B, and c are not real running levels)

3. The action field defines the status in which the process should run:

Boot runs when the system starts, ignoring runlevel
Bootwait runs when the system starts and init waits for the process to complete. Ignore runlevel
Ctrlaltdel run when Ctrl + Alt + Del are pressed simultaneously, and the SIGINT signal is sent to init. Ignore runlevel
Initdefault: do not execute this process. It is used to set the default runlevel.
Kbrequest runs when init receives a signal from the keyboard. The keyboard combination is required to comply with KeyBoardSigral (see/usr/share/doc/kbd-* Documents on the keyboard combination)
Off indicates that the process is not running.
Once every runlevel runs once
Ondemand runs when the system specifies A specific running level A, B, and C.
Powerfail runs when init receives the SIGPWR Signal
Powerokwait runs when the SIGPWD signal is received and the power status in the/etc/file contains OK
Powerwait runs when it receives the SIGPWD signal and init waits for the process to end
Respawn restarts the process at any time
Sysinit runs before running the boot or bootwait Process
Wait running process waiting for Input Running Mode
The process field contains the process executed by init. The process adopts the same format as running the process on the command line,

Therefore, the process field starts with the name of the process, followed by the parameter to be passed to the process during running.

For example,/sbin/shutdown-t3-r now, the process is executed when Ctrl + Alt + Del is pressed. You can also enter it in the command line to restart the system.

4. The Process in the Process field can be any waiting Process, executable script or program.

In addition, you can add new record items in the file inittab at any time. Level Q/q does not change the current running level, and re-check the inittab file, you can run init Q or init q to re-read the init process and process the inittab file.

It will first execute/etc/init. d/rcS
#! /Bin/sh

/Bin/mount-
Mdev-s

Mount-a will execute/etc/fstab
Proc/proc defaults 0 0
None/tmp ramfs defaults 0 0
Mdev/dev ramfs defaults 0 0
Sysfs/sys sysfs defaults 0 0

Mount some ramfs.
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.