In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "what the Linux system startup process is like", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Linux system startup process is how" this article.
When linux starts, we will see a lot of startup information. The startup process of Linux system is not as complicated as we think. The process can be divided into five stages: kernel boot, running init, system initialization, establishing terminal, and user login system.
LINUX startup process
First, through a diagram to simply understand the whole system startup process, the whole process can be divided into POST- > BIOS- > MBR (GRUB)-> Kernel- > Init- > Runlevel. The role of each process is described in detail below.
Linux boot process details: BIOS- > MBR- > GRUB- > KernelLinux boot process details: BIOS- > MBR- > GRUB- > KernelBIOS
BIOS (Basic Input/Output System), the basic input and output system, the system is stored on the ROM chip of the motherboard. When the computer is powered on, it will first read the system, and then there will be a power-on self-test process, this process is actually to check CPU and memory, the most basic components of the computer (controller, calculator and memory), but also check other hardware, if there is no exception, begin to load BIOS programs into memory. Let's not talk about the detailed BIOS function here. One of the main functions of BIOS is to store the boot order of the disk. BIOS will look up the MBR information of the first disk head according to the startup order, and load and execute the Bootloader program in MBR. If the first disk does not have MBR, it will continue to find the second disk (PS: the boot sequence can be set in the BIOS interface). Once the BootLoader program is detected and loaded into memory BIOS transfers control to the BootLoader program.
MBR
MBR (Master Boot Record), master boot record, MBR is stored in the head of the disk, the size is 512bytes, wherein, 446bytes is used to store BootLoader programs, 64bytes is used to store partition table information, and finally 2bytes is used to check the validity of MBR.
Linux boot process details: BIOS- > MBR- > GRUB- > KernelLinux boot process details: BIOS- > MBR- > GRUB- > KernelGRUB
GRUB (Grand Unified Bootloader), multi-system startup program, its execution process can be divided into three steps:
Stage1: this is actually MBR, its main job is to find and load the second Bootloader program (stage2), but when the system is not started, MBR can not find the file system, it can not find the location where stage2 is stored, so there is stage1_5
Stage1_5: this step is to identify the file system
The Stage2:GRUB program looks for Kernel information based on the / boot/grub/grub.conf file, and then starts loading the Kernel program. When the Kernel program is detected and loaded into memory, GRUB transfers control to the Kernel program.
PS: in fact, this step / boot has not been mounted yet. GRUB directly identifies the file system of the disk where grub resides, so it should actually be / grub/grub.conf file. The information of this configuration file is as follows:
Grub.conf:#boot=/dev/sdadefault=0 # sets the number of title launched by default Starting at 0, timeout=5 # waits for the user-selected timeout splashimage= (hd0,0) / boot/grub/splash.xpm.gz # GRUB background image hiddenmenu # Hidden menu title CentOS (2.6.18-194.el5PAE) # Kernel title root (hd0,0) # device kernel / vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/ # Kernel file path and the parameter initrd / initrd-2.6 passed to the kernel. 18-194.el5PAE.img # ramdisk file path Kernel
Kernel, kernel and Kernel are the main programs of Linux system. In fact, the files of Kernel are very small, only the most basic modules are retained, and are stored in the hard disk in the form of compressed files. When GRUB reads Kernel into memory, memory begins to decompress the kernel files. When talking about kernel startup, we should first talk about the file initrd.
Initrd (Initial RAM Disk), which is copied into memory at the stage2 step, is a temporary root file system (rootfs) that is generated when the system is installed. Because Kernel only retains the most basic modules in order to simplify, therefore, there are no drivers for all kinds of hardware on Kernel, so you can't recognize the device where rootfs is located, so the file initrd is generated, which loads the necessary driver modules. When Kernel starts, you can load the driver modules from the initrd file until the real rootfs is mounted, and then remove the initrd from memory.
Kernel mounts the root file system read-only, and when the root file system is mounted, it starts loading the first process (the process in user space), executes / sbin/init, and then transfers control to the init program.
Init
Init, initialization, as the name implies, this program is to initialize OS, which actually executes the script according to the action set by / etc/inittab (defines the default run level of the system). The first script to be executed is / etc/rc.d/rc.sysinit, which is the real OS initialization script. Briefly describe the tasks of this script (you can take a look at the actual script to see what has been done):
Activate udev and selinux; to set kernel parameters based on / etc/sysctl.conf file; set system clock; mount hard disk mapping; enable swap partition; set hostname; root file system detection and read-write remount of root file system; activate RAID and LVM devices; enable disk quotas; check and mount other file systems based on / etc/fstab; clean up expired locks and PID files
After execution, according to the startup level of the configuration, execute the script under the corresponding directory, and finally execute the script / etc/rc.d/rc.local. At this point, the system boot is complete.
Runlevel
Runlevel, run level, different levels will start different services. Init will execute scripts in the corresponding directory according to the defined level. The startup levels of Linux can be divided into the following
0: shutdown mode 1: single user mode (directly entered as administrator) 2: multiuser mode (no network) 3: multiuser mode (command line) 4: reserved 5: multiuser mode (graphical interface) 6: restart
At different run levels, the script / etc/rc.d/rc executes scripts in different directories
Run level 0-/ etc/rc.d/rc0.d/Run level 1-/ etc/rc.d/rc1.d/Run level 2-/ etc/rc.d/rc2.d/Run level 3-/ etc/rc.d/rc3.d/Run level 4-/ etc/rc.d/rc4.d/Run level 5-/ etc/rc.d/rc5.d/Run level 6-/ etc/rc.d/rc6.d/
The scripts in these directories only start with K and S, the files starting with K are the services that need to be disabled for booting, and the files starting with S are the services that need to be enabled for booting.
Linux boot process details: BIOS- > MBR- > GRUB- > KernelLinux boot process details: BIOS- > MBR- > GRUB- > Kernel above are all the contents of this article "what the Linux system startup process is like", thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.