|
1 Linux boot process
-------------------------------------------------- ------------------------------
1.1 load the BIOS hardware information and self-test, and according to the set to get the first bootable device
-------------------------------------------------- ------------------------------
BIOS (Basic Input Output System): The system loads the BIOS and loads the CMOS information through the BIOS, and obtains the hardware configuration of the host computer through the settings in the BIOS. The BIOS performs power-on self-test according to the acquired information. Self Test, POST), and determine the bootable device sequence.
1.2 read and execute the first boot device MBR boot loader (that is, grub, spfdisk boot management program)
-------------------------------------------------- ------------------------------
As the different os filesystem format is different from the need to boot management program to handle the core file load (load), the so-called boot loader. Boot loader program installed in the first boot device in the first sector (sector), that MBR (Master Boot Record, the main boot record area, 446bytes). The BIOS reads the MBR through the INT13 interrupt. Each operating system will install a default boot loader to his own file system, which is a prerequisite for multi-system.
1.3 According to the boot loader settings loaded Kernel, Kernel will begin to detect the hardware and load the driver
-------------------------------------------------- ------------------------------
Boot loader According to the set to read the kernel file, and extract to memory, Kernel will start to detect the hardware and load the driver. The kernel is usually in the / boot / vmlinuz-core version, and the kernel can load the kernel modules dynamically (the disk drives are in the form of modules), which are placed in the / lib / modules / directory.
Initial RAM Disk: / boot / initrd, loaded into the memory through the boot loader into a root directory simulation, the virtual file system can provide an executable program, through the boot process to load the process The most needed core module.
Boot loader by loading the kernel and initrd, and then extract the initrd into memory in the root directory, Kernel will be able to load the appropriate driver, the final release of the virtual file system, and mount the actual root directory file system, you can start Follow-up of the normal boot process.
1.4 in the hardware driver is successful, Kernel will automatically start the init program, and init will get run-level information
-------------------------------------------------- ------------------------------
The kernel starts the first program, / sbin / init, and prepares the environment for software execution, including the system's hostname, network settings, language handling, file system format, and other services. The configuration file is / etc / inittab. Inittab will also get run-level (boot execution level).
1.5 init Execute the /etc/rc.d/rc.sysinit file to prepare the software execution environment (such as network, time zone, etc.)
-------------------------------------------------- ------------------------------
Init processes the system initialization process (/etc/rc.d/rc.sysinit), including the decision whether to start SELinux, read the network configuration file / etc / sysconfig / network, user-defined module load / etc / sysconfig / modules / * .modules to fsck check disk file system: filesystem check, clear the boot process of the temporary file, the boot-related information to load / var / log / dmesg file medium.
1.6 init start-run the implementation of the various services (script)
-------------------------------------------------- ------------------------------
Start the system service and the relevant startup configuration file (/etc/rc.d/rc N & / etc / sysconfig) based on run-level. For example, run-level to 5, that is, when the graphical interface starts, it will execute the /etc/rc5.d/ directory script, each script is a real point /etc/init.d/ directory corresponding to the startup script. The last one executed is /etc/rc.d/rc.local.
1.7 init Execute the /etc/rc.d/rc.local file
-------------------------------------------------- ------------------------------
Execute the user-defined start-up program /etc/rc.d/rc.local.
1.8 init Execute the terminal emulation program mingetty to start the login program, and wait for the user to log in
2 boot process of the relevant documents and key points
-------------------------------------------------- ------------------------------
2.1. The configuration file for module loading: /etc/modprobe.d / *. Conf: (The /etc/modprobe.conf file is no longer used in CentOS 6.5).
2.2. / Etc / sysconfig / *: boot configuration file to read during the process, including authconfig (authentication mechanism for user authentication), network-scripts / * (network card settings).
2.3. About the Core and Core Modules (driver modules):
Core: / boot / vmlinuz or / boot / vmlinuz-version;
Core decompress the required RAM Disk: / boot / initrd (/ boot / initrd-version);
Kernel module: / lib / modules / version / kernel or / lib / modules / $ (uname -r) / kernel;
Core source: / usr / src / linux (default is not installed)
Core version: / proc / version
System core functions: / proc / sys / kernel
Two ways to add new hardware driver module: re-compile the core, and add the appropriate driver source code; the hardware driver compiled into a module, at boot time to load the module.
Dependencies of the kernel modules: / lib / modules / $ (uname-r) / The modules dependencies are documented in the /lib/modules/$(uname-r)/modules.dep file, using the depmod command to create the files .
Kernel module related commands: lsmod - shows the module already exists in the core, module dependency will also be displayed
Modinfo - Displays a module's details
Modpobe - automatically analyze the module dependencies (modprobe.dep) and load the module, -r remove the module
Insmod - Manually load the full file name of the module
Rmmod - remove the module, -f force to remove, -w wait to use and then removed
Ps: insmod, rmmod operation module dependent, unable to complete the operation.
2.4. Initrd: initrd file contains / lib / modules / $ (uname-r) / kernel / which boot the necessary modules at boot time through the host INT13 hardware function to read out the file to extract, initrd in memory simulation become Root directory, as this virtual file system (Initial RAM Disk) mainly contains the disk and file system module, the core will finally be able to identify the actual disk, you can mount the actual root directory. Use the mkinitrd command to re-create the initrd file: mkinitrd [-v] [--with = module name] initrd file name Core version
2.5. About the boot management artifact grub:
Through the configuration file /boot/grub/menu.lst to modify and increase the startup items, increase the startup items need to install the main program to the system through grub (such as setup (hd0), such as MBR (hd0) or boot sector Hd0,0) and so on
For a boot entry encryption: grub-md5-crypt, access to the encrypted password, add the menu.lst file in the title below the first line, eg: title CentOS
Password --md5 $ 1 $ kvlI0 / $ byrbNgkt / .REKPQdfg287.
Unsafe: The user can enter the menu through edit mode (e) and delete the password field and press b to start the boot process, so encrypt the menu.lst file: put the password in front of all the titles, Lock the title with lock below to lock, the boot entry can only be pressed to unlock p. |
|
|
|