Describes the Linux Startup Process and the configuration files and scripts used for Linux Startup.

Source: Internet
Author: User

Detailed description of the Linux Startup Process and the configuration files and scripts used for the startup: Detailed description of the Linux Startup Process and the configuration file to be used POST power-on self-check --> BIOS (Boot Sequence) -> MBR (bootloader)-> Kernel-> initrd-> rootfs (/sbin/init): POST (power-on self-check) the computer itself does not execute any program, so the system must complete the self-lifting process, under the control of the CPU, map a program in the RAM chip to the ROM address space, and execute the commands to check the health status of the system hardware, such as storage devices, NICS, CPUs, sound cards, and other hardware devices. After the check is completed, all the hardware, basic hardware, and core hardware are correct. The next Boot process-> BIOSBIOS (Boot Sequence) follows the BIOS-defined system Boot process, find the MBR of the operating system on the corresponding storage device from top to bottom based on the Boot Sequence. If the MBR exists, the bootloaderMBR (bootloader) in the MBR will be read) find the bootloader in the system partition based on the active partition guided by MBR. bootloader is called a program and occupies 446 bytes. The position of the kernel of the operating system to be guided is configured in the bootloader. Therefore, after the BIOS is loaded into the memory, after the BIOS transfers the control permission to the bootloader, bootloader receives the control permissions of the entire system, then reads the kernel in the corresponding operating system based on the user's choice, loads the kernel into a certain space location in the memory, decompress, at this time, the kernel can be active in the memory, and explore the hardware in the memory based on the kernel function, load the hardware driver, and initialize the kernel. the bootloader transfers the control permission to the kernel. Kernel (initialization) We know that kernel is used to explore hardware, load hardware drivers, and mount the root file system in read/write mode. So here is a strange problem. What is the problem? We also know that to access the real root file system (rootfs), you must load the device in the root file system. At this time, the root file system is not mounted, what should I do if I need to mount the root file system and load the driver in the root file system? The initrd file is used. Here is a brief summary of what kernel initialization will do: hardware probe> initrd> root file system mounting> rootfs (/sbin/init) initrd is actually a Virtual File System with directories such as/, lib, bin, sbin, usr, proc, sys, var, dev, and boot, in fact, you will find the directory inside is a bit like true/right, so we call it a virtual root file system. The function is to associate the kernel with the real root file system, let the kernel load the driver required by the root file system in initrd, mount the root file system in read/write mode, and run the first process init in the user. /Sbin/init (/etc/inittab)/sbin/init start will use the entries defined by/etc/inittab, such as: Default Login level id: 3: initdefault :( here is the default startup level 3) Next let's talk about what/etc/inittab is working on:/etc/inittab default running level 0: halt1: single user mode (single user maintenance mode) 2: multi user mode, without NFS (NFS function not supported) 3: multi user mode, text mode (character Interface) 4: reserved (system retained) 5: multi user mode, graphic mode (graphical interface) 6: reboot (restart) system initialization (/etc/rc. d/rc. sysinit) detection, and mount the root file system in read/write mode to set the host name detection and mount other file systems in/etc/fstab to start swap partition initialization peripheral hardware device driver according to/etc/sysctl. conf sets kernel parameters to activate udev and selinux to activate LVM and RAID devices to clear expired lock files and PID file loading key ing --> run the service script/etc/at the specified level for each key on the keyboard/ rc. d/init. d // etc/rc. d/rc #. d rc0-rc6 K * # As long as the files starting with K are executed stop work S * # As long as the files starting with S are executed start work 0-99 (execution order, the smaller the number, the earlier it is executed.) init executes/etc/rc. d/rc. localinit executes the interrupt host simulation program mingetty to start the login process, and finally waits for the user to log on to the syntax and format of/etc/inittab below: /etc/inittab format and syntax (:) [setting options]: [runlevel]: [init Operation Behavior]: [Command Options] setting options: indicates the running level of init's main work options-0-6 init Operation Behavior: initdefault: indicates the default running level sysinit: indicates the system initialization Operation Option ctrlaltdel: indicates the restart related settings wait: indicates that the respawn operation can be executed after the execution of the previous command is completed. This indicates that the following fields can be reboot without restriction. Some commands are supported, but usually the init process of the script is used: processing Based on/etc/inittab settings: By default Level 3 Description: id: 3: initdefault: default runlevel->/etc/rc. d/rc. sysinit->/etc/rc. d/rc5.d-> ctrlatdel-> set "pf" and "pr"-> mingetty-> login init process system initialization process/etc/rc. d/rc. sysinit (set the system environment) obtain the network environment and host type->/etc/sysconfig/network test and mount the memory device/proc and/sysSElinux. Set the terminal font. Set the welcome page during system startup. system Time and time zone settings/etc/sysconfig/clock interface device detection User-Defined module loading->/etc/sysconfig/modules /*. modules according to/etc/sysctl. conf sets kernel parameters to initialize the software disk array->/etc/mdadm. conf initializes the LVM file system function fsck to detect disk file system disk quotas, and re-mount the root file system in read/write mode to clear the temporary files that will be started during the cleanup process->/var/log/dmesg startup service and related STARTUP configuration files (/etc/ rc. d/rc # &/etc/sysconfig) by default Level 3 Description: id: 3: initdefault: l3: 3: wait:/etc/rc. d/rc 3 find/etc/rc. d/rc3.d starts with K * and runs/etc/rc. d/rc3.d/K * stop the file starting with S * and run/etc/rc. d/rc3.d/S * start/etc/rc. d/rc #. all files in d/are linked to/etc/rc. d/init. d file User-Defined boot Startup Program (/etc/rc. d/rc. local) You can write some execution commands or scripts to/etc/rc as needed. d/rc. local, you can load it when it is started. Call login according to the mingetty program to log on to the user-> log on to the user (complete system startup)

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.