Because of the different BIOS functions, it consists of two parts: the POST code runtime service. After the POST is completed, it will be cleared from the memory, but the BIOS runtime service will be retained for the target operating system.
To start the operating system, the BIOS runtime service searches for the activated or boot-able devices, the search sequence is determined by the CMOS settings (that is, the boot sequence we usually call in BIOS ). A soft drive, an optical drive, a partition on a hard disk, a network device, or even a usb flash drive, can be used as a boot device.
Of course, linux is usually started from a hard disk. The MBR (Master boot Record) on the hard disk contains a basic boot loader, which is a 512-byte sector located in the first sector of the disk (0 head, 0 track, 1 sector ). When the MBR is loaded into RAM, the BIOS transfers the control to the MBR.
Vim/etc/grub. conf
Root (hd0, 0)
Use MBR to go to the Operating System Management menu (/etc/grub. conf hiddenmenu management menu is hidden by default ).
Kernel functions: Drive hardware, manage memory, and schedule tasks.
Ll-h/boot/vmlinuz *** the kernel is very small 1.8 m
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
# Whether to press [ctrl] + [alt] + [del] to restart the configuration item:
Ca: ctrlaltdel:/sbin/shutdown-t3-r now
Excerpt:
Init process and inittab boot command
The init process is the starting point of all processes in the system. After the kernel completes the kernel boot, it loads the init program in the current thread (process) space. Its Process number is 1.
The init program needs to read the/etc/inittab file as its behavior pointer. inittab is a descriptive (non-executive) Text of the behavior unit. Each Command Line has the following format:
Id: runlevel: action: process where id is the entry identifier, runlevel is the running level, action is the action code, and process is the specific execution program.
Generally, the id must be within four characters. For getty or other login program items, the id must be the same as the tty number. Otherwise, the getty program will not work properly.
Runlevel is the identifier of the running level of init. It is generally 0-6 and S or s. The running levels 0, 1, and 6 are retained by the system, 0 is used as the shutdown action, 1 is used as the restart to the single-user mode, and 6 is used as the restart; S and s have the same meaning, indicating the single-user mode, the inittab file is not required, so it does not appear in inittab. In fact, when you enter single-user mode, init runs/sbin/sulogin directly on the console (/dev/console.
In general system implementation, 2, 3, 4, and 5 are used. In the Redhat system, 2 indicates that the multi-user mode is not supported by NFS, 3 indicates full multi-user mode (also the most common level), 4 is reserved for user customization, and 5 indicates XDM graphical login mode. The 7-9 level can also be used. Traditional Unix systems do not define these levels. Runlevel can be multiple parallel values to match multiple running levels. For most actions, runlevel is executed only when it matches the current running level.
Initdefault is a special action value used to identify the default startup level. When init is activated by the core, it reads the initdefault item in inittab and obtains the runlevel, as the current running level. If there is no inittab file or there is no initdefault item, init will request to enter runlevel on the console.
Actions such as sysinit, boot, and bootwait will run unconditionally at system startup, while ignoring runlevel. Other actions (excluding initdefault) are related to a certain runlevel.
Id: 3: initdefault:
# Indicates that the current default running level is 3-full multi-task mode;
Si: sysinit:/etc/rc. d/rc. sysinit
# Automatically execute the/etc/rc. d/rc. sysinit script at startup
L3: 3: wait:/etc/rc. d/rc 3
# When the runtime level is 3, run the/etc/rc. d/rc Script with the parameter 3. init will wait for its return
0: 12345: respawn:/sbin/mingetty tty0
# Run the/sbin/mingetty program with tty0 as the parameter at each level from 1 to 5. Open the tty0 terminal
# Log On As a user. If the process exits, run the mingetty program again.
X: 5: respawn:/usr/bin/X11/xdm-nodaemon
# Run The xdm program at level 5, provide the xdm graphical login interface, and re-execute it upon exit
Figure:
Author "do not eat tomatoes"