Article Title: Linux system startup process and Grub configuration method. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
I. Linux Startup Process
1. From BIOS to KERNEL
BIOS self-check-> MBR (GRUB)-> KERNEL self-decompression-> KERNEL initialization-> KERNEL startup
2. Start the kernel: Create a 1 # process and execute it. It creates several kernel threads, and then loads and executes the program/sbin/init (into a user process ). Later, init executes the corresponding script based on the/etc/inittab configuration file for system initialization, such as setting the keyboard, Font, loading module, and network.
For Redhat, the execution sequence is:
/Etc/rc. d/rc. sysinit # The first script executed by init
/Etc/rc. d/rc $ RUNLEVEL # init executes various scripts of the specified running level ($ RUNLEVEL is the default running mode;
/Etc/rc. d/rc. local # scripts run in the following modes: 2, 3, and 5
/Sbin/mingetty (or getty) # Wait for the user to log on
The/etc/inittab specifies the RUNLEVEL of the system. init starts related services (some background processes) based on the running level to implement different functions.
RUNLEVEL: 0-6
0: halt, 1: single user, 2: multi-user, 3: multi-user and start NFS service
4: reserved; 5: Run xdm (X window) to log on as a graphical interface
6: reboot
3./etc/inittab File
The content of the/etc/inittab file is as follows:
# Set the default RUNLEVEL for system startup:
Id: 3: initdefault:
# The configuration file used to detect and initialize the system environment before starting the RUNLEVEL service:
Si: sysinit:/etc/rc. d/rc. sysinit
# Seven scripts placement paths for services with different run levels to be started:
L0: 0: wait:/etc/rc. d/rc 0
L1: 1: wait:/etc/rc. d/rc 1
L2: 2: wait:/etc/rc. d/rc 2
L3: 3: wait:/etc/rc. d/rc 3
L4: 4: wait:/etc/rc. d/rc 4
L5: 5: wait:/etc/rc. d/rc 5
L6: 6: wait:/etc/rc. d/rc 6
# Whether to press [ctrl] + [alt] + [del] to restart the configuration item:
Ca: ctrlaltdel:/sbin/shutdown-t3-r now
# Number of enable terminals on the local machine:
1: 2345: respawn:/sbin/mingetty tty1
2: 2345: respawn:/sbin/mingetty tty2
3: 2345: respawn:/sbin/mingetty tty3
4: 2345: respawn:/sbin/mingetty tty4
5: 2345: respawn:/sbin/mingetty tty5
6: 2345: respawn:/sbin/mingetty tty6
# Start the script setting project in the X Window (RUNLEVEL 5) Environment:
X: 5: once:/etc/X11/preofdm-nodaemon
The syntax of this file is as follows:
Identifier: Level: init Action Behavior: Command item
1. identifier:
A maximum of four characters, representing the main work item of init, is a simple description.
2. Level:
Which run level does the project mean. If it is 35, runlevel 3 and 5 are executed.
3. init action:
The main actions that can be performed are as follows:
Initdefault: indicates the default run level value;
Sysinit: indicates the action item initialized by the system;
Ctrlaltdel: Specifies whether the three buttons [ctrl] + [alt] + [del] can be restarted;
Wait: indicates that the subsequent action can be continued only after the command project is executed;
Respawn: indicates that init will start again.
For more settings, see man inittab.
4. Command items:
That is, the commands that should be able to be executed are usually scripts ??? BR>
Note: If the init program is executed based on the above files, the following functions are completed based on the content of the/etc/inittab file.
(1) Get RUNLEVEL (the row id in the file: 3: initdefault :) is 3
(2) Run rc. sysinit (this line of si: sysinit:/etc/rc. d/rc. sysinit in the file)
(3) run/etc/rc. d/rc3.d directory script (this line in the file l3: 3: wait:/etc/rc. d/rc 3, and the RUNLEVEL in this example is 3)
(4) then set whether to press [ctrl] + [alt] + [del] to restart the system (this line of ca: ctrlaltdel in the file: /sbin/shutdown-t3-r now. If not, comment out this line)
(5) start six terminal interface tty1-tty6
(6) If we use run level 5, apart from the six terminals, init will also execute/etc/X11/preofdm-nodaemon. Its main function is to start X Window!
[1] [2] Next page