Because the file system format of the operating system is different, self-check and boot require a boot management program to process and load the core. this core is called BOOTLoader, which exists in the first sector, that is, MBR (master boot record ). BIOS reads MBR through hard disk interruption INT13. Each type...
Self-check and guidance
Because the file system format of the operating system is different, a boot management program is required to process the loading.
The core is the BOOT Loader, which exists in the first sector, that is, MBR (Main
Boot Records ). BIOS reads MBR through hard disk interruption INT13.
Each operating system has its own Boot loader, and each file system or partition retains a Boot sector.
Install boot loader in the operating system.
Boot loader in multiple operating systems: provides menus, loads core files, and transfers them to other loaders.
Loading Core Detection hardware and initrd functions
After the boot loader reads the core file, linux decompress the core to the primary storage, and uses the core
Function testing and driver devices.
Core files stored in:/boot File name:/boot/vmlinuz-2.6.18-164.el5
To facilitate developers, linux can dynamically load core modules (/lib/modules ).
To ensure that the file system is not affected during boot, the root directory is mounted in read-only mode during boot.
When the core cannot identify the disk, and the disk driver is in/lib/modules, the driver cannot be read if the root directory cannot be mounted.
. In this case, you can use the virtual file system to solve the problem.
Virtual File System, File name:/boot/initrd-2.6.18-164.el5.img, which can be loaded into memory through boot loader
And then decompress the package and simulate a root directory in the memory. this simulation root directory can provide executable programs.
Through this program to load the core modules required during the boot process. The core module includes USB, RAID, LVM, and SCSI
And then call/sbin/init again...
Init and/etc/inittab and runlevel
The first program of the core call,/sbin/init (PID = 1) The main function of preparing the software execution environment, including the system host name, network
Set, language processing, file system format, and other services. All actions are planned through the init configuration, namely,/etc/inittab.
Runlevel requires different services and different environments. There are seven levels:
0-halt 1-single user mode 2-Multi-user, without NFS
3-Full multi-user mode 4-unused 5-X11
6-reboot
Process set by init:
1. obtain the runlevel level, for example, 5. use/etc/rc. d/rc. sysinit for initial system conversion.
3. perform l5: 5: wait:/etc/rc. d/rc 5 based on runlevel 5. set the ctrl + alt + del key combination function.
5. set UPS pf and pr mechanism 6. start six terminals of mingetty
7. finally, start the graphic interface with/etc/x11/perofdm-nodaemon.
Init process system initialization process/etc/rc. d/rc. sysinit
In the/etc/inittab, si: sysinit:/etc/rc. d/rc. sysinit uses/etc/rc. d/rc. sysinit to set the system environment.
Start system services and related startup configuration files
After the above process, the system works smoothly, but related services must be started. Based on the runlevel setting value in/etc/inittab
Determine the service project to start. For example, runlevel 3
Id: 3: initdefault: # runlevel settings
# System initialization.
Si: sysinit:/etc/rc. d/rc. sysinit
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 # start with this setting
L4: 4: wait:/etc/rc. d/rc 4
L5: 5: wait:/etc/rc. d/rc 5
L6: 6: wait:/etc/rc. d/rc 6
Start the service in the/etc/rc3.d folder.
[Root @ lyy grub] # cd/etc/rc3.d/
[Root @ lyy rc3.d] # ll
Total 4
Lrwxrwxrwx 1 root 17 12-16 21:04 K01dnsmasq->.../init. d/dnsmasq
Lrwxrwxrwx 1 root 24 12-16 K02avahi-dnsconfd-> ../init. d/avahi-dnsconfd
Lrwxrwxrwx 1 root 24 12-16 21:04 K02NetworkManager-> ../init. d/NetworkManager
---------- Below --------------------------
Features:
All files are Sxx or Kxx, where xx is a number, and numbers are correlated between files.
All are continuous files. link them to the stand alone Service Startup directory/etc/init. d.
User-defined boot startup program
The/etc/rc. d/rc. local file can execute the system commands you want to execute.
Set the loading terminal or x-window interface according to/etc/inittab
# Run gettys in standard runlevels
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
The preceding code indicates that at runlevel 2345, six/sbin/mingetty will be executed, so we have six text terminals.
If you want to provide only three at boot, you can modify the above content, the tty3-5 with # Comment
If runlevel5 provides six text terminals, it also executes the Command/etc/X11/preofdm-nodaemon.
Run level switch
Switch to run level 3 in the run level 5 system. The system will:
First, compare the files starting with K and S in/etc/rc3.d and/etc/rc5.d;
Multiple K-start files are closed in the new runlevel, that is, in/etc/rc3.d;
In the new runlevel, that is, the/etc/rc3.d file starts with S.
Author "Liyy study notes"