linux mbr grub is the process of starting the entire Linux system. The full English name of mbr is "Master Boot Record", which means the master boot record. mbr is stored in the head of the disk and has a size of 512 bytes; the full English name of grub is It is "Grand Unified Bootloader", which means multi-system bootloader.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
What is linux mbr grub?
Detailed explanation of the Linux boot process: BIOS->MBR->GRUB, etc...
Overview
Linux is a A free and open source UNIX-like operating system. The operating system's kernel was first released by Linus Torvalds on October 5, 1991. After adding user space applications, it becomes the Linux operating system. Linux is the most famous example of free software and open source software development.
Let’s briefly record the entire process of the Linux system from booting to being usable, as a reminder!
LINUX startup process
Let’s first briefly understand the entire system startup process through a picture. The entire process can basically be divided into POST-->BIOS-- >MBR(GRUB)-->Kernel-->Init-->Runlevel. The role of each process is explained in detail below.
BIOS
BIOS (Basic Input/Output System), the basic input and output system, this system is stored in the ROM chip of the motherboard When the computer is turned on, it will first read the system, and then there will be a power-on self-test process. This process is actually to check the CPU and memory, the most basic components of the computer (controller, arithmetic unit and memory). It will also check other hardware, and if there are no abnormalities, it will start loading the BIOS program into the memory. The detailed BIOS functions will not be discussed here. One of the main functions of the BIOS is to store the startup sequence of the disk. The BIOS will search for the MBR information of the first disk header according to the startup sequence, and load and execute the Bootloader program in the MBR. , if the MBR does not exist on the first disk, it will continue to search for the second disk (PS: the startup sequence can be set in the BIOS interface). Once the BootLoader program is detected and loaded into the memory, the BIOS will transfer control to BootLoader program.
MBR
MBR (Master Boot Record), master boot record, MBR is stored at the head of the disk, with a size of 512 bytes, of which 446 bytes are used to store the BootLoader program , 64 bytes are used to store partition table information, and the last 2 bytes are used for MBR validity check.
GRUB
GRUB (Grand Unified Bootloader), a multi-system startup program, its execution process can be divided into three steps:
Stage1: This is actually the MBR. Its main job is to find and load the second Bootloader program (stage2). However, when the system is not started, the MBR cannot find the file system at all, so it cannot be found. The location where stage2 is stored, therefore, there is stage1_5
Stage1_5: This step is to identify the file system
Stage2: The GRUB program will search for the Kernel based on the /boot/grub/grub.conf file information, and then starts loading the Kernel program. When the Kernel program is detected and loaded into the memory, GRUB hands over control to the Kernel program.
PS: In fact, /boot has not been mounted in this step. GRUB directly recognizes the file system of the disk where grub is located, so it should actually be the /grub/grub.conf file. The information of this configuration file is as follows:
grub.conf:
#boot=/dev/sda default=0 #设定默认启动的title的编号,从0开始 timeout=5 #等待用户选择的超时时间 splashimage=(hd0,0)/boot/grub/splash.xpm.gz #GRUB的背景图片 hiddenmenu #隐藏菜单 title CentOS (2.6.18-194.el5PAE) #内核标题 root (hd0,0) #内核文件所在的设备 kernel /vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/ #内核文件路径以及传递给内核的参数 initrd /initrd-2.6.18-194.el5PAE.img #ramdisk文件路径
Kernel
Kernel, kernel, Kernel is the most important program in the Linux system. In fact, Kernel files are very Small, only the most basic modules are retained and stored on the hard disk in the form of compressed files. When GRUB reads the Kernel into the memory, the memory begins to decompress the kernel file. When talking about kernel startup, we should first talk about the initrd file,
initrd (Initial RAM Disk), which is copied to the memory in the stage2 step. This file is generated when installing the system and is a temporary The root file system (rootfs). Because Kernel only retains the most basic modules in order to simplify it, there are no drivers for various hardware on the Kernel, so it cannot recognize the device where rootfs is located. Therefore, the initrd file is generated, which loads the necessary driver modules. , when the Kernel starts, the driver module can be loaded from the initrd file until the real rootfs is mounted, and then the initrd is removed from the memory.
Kernel will mount the root file system in read-only mode. When the root file system is mounted, it will start to load the first process (user space process), execute /sbin/init, and then control The power is transferred to the init program.
Init
init,初始化,顾名思义,该程序就是进行OS初始化操作,实际上是根据/etc/inittab(定义了系统默认运行级别)设定的动作进行脚本的执行,第一个被执行的脚本为/etc/rc.d/rc.sysinit,这个是真正的OS初始化脚本,简单讲下这个脚本的任务(可以去看看实际脚本,看看都做了什么):
激活udev和selinux;
根据/etc/sysctl.conf文件,来设定内核参数;
设定系统时钟;
装载硬盘映射;
启用交换分区;
设置主机名;
根文件系统检测,并以读写方式重新挂载根文件系统;
激活RAID和LVM设备;
启用磁盘配额;
根据/etc/fstab,检查并挂载其他文件系统;
清理过期的锁和PID文件
执行完后,根据配置的启动级别,执行对应目录底下的脚本,最后执行/etc/rc.d/rc.local这个脚本,至此,系统启动完成。
Runlevel
runlevel,运行级别,不同的级别会启动的服务不一样,init会根据定义的级别去执行相应目录下的脚本,Linux的启动级别分为以下几种
0:关机模式
1:单一用户模式(直接以管理员身份进入)
2:多用户模式(无网络)
3:多用户模式(命令行)
4:保留
5:多用户模式(图形界面)
6:重启
在不同的运行级别下,/etc/rc.d/rc这个脚本会分别执行不同目录下的脚本
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/
这些目录下的脚本只有K*和S*开头的文件,K开头的文件为开机需要执行关闭的服务,S开头的文件为开机需要执行开启的服务。
相关推荐:《Linux视频教程》
The above is the detailed content of What is linux mbr grub. For more information, please follow other related articles on the PHP Chinese website!

The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.

The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.

Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.

The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.

Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6
Visual web development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Notepad++7.3.1
Easy-to-use and free code editor
