Steps to repair grub.cfg file corruption in Linux system

Steps to repair grub.cfg file corruption in Linux system

1. Introduction to grub.cfg file

1. grub.cfg file location

/boot/grub2/grub.cfg

[root@node1 grub2]# ls
device.map fonts grub.cfg grubenv i386-pc
[root@node1 grub2]# pwd
/boot/grub2
[root@node1 grub2]# 

2. Function of grub.cfg file

grub is a program that boots the operating system. It will boot the kernel according to its own configuration file. After the kernel is loaded into the memory,
The kernel will find the driver corresponding to the file system used by the root partition according to the configuration in the grub configuration file, and mount the root partition through the driver corresponding to the root partition file system, thereby achieving the purpose of starting the operating system.

3. Introduction to system startup process

1. Load MBR into memory, MBR = 512 bytes = boot program (446 bytes) + 64 bytes (partition table) + 2 bytes 2. BIOS loads the grub boot program, and system control is handed over to the boot program.
3. The boot program loads the configuration file /boot/grub2/grub.cfg, tells the partition where the /boot directory and the kernel file are located, and loads the kernel and initramfs and puts them into memory.
initramfs contains the kernel modules and initialization scripts necessary for the hardware to boot.
4. The kernel initializes itself, and the kernel finds the drivers for all the hardware in initramfs and initializes the hardware.
5./sbin/init in initramfs is started as a process with pid 1 and linked to systemd.
6. The kernel switches root from initramfs to the real root.
7. Start the first program systemd

2. The grub.cfg file is damaged, and the system boots up and starts the interface

insert image description here

3. Repair steps

1. Specify the partition where the /boot directory is located

insert image description here

2. Load the kernel file and mount the root partition in read-only mode

insert image description here

3. Specify initramfs file

insert image description here

4. Start

insert image description here

5. Enter the system and regenerate the grub.cfg file

insert image description here

Note: When mounting the root partition, fill in the information according to the actual situation. Generally, when the system is installed by default and the system disk is in nvme format, the root partition is /dev/nvme0n1p3.

The system disk is a SATA hard disk, and the root partition is generally /dev/mapper/rhel-root, or it is a customized system partition when you install the system yourself.

This concludes the article on how to repair a damaged grub.cfg file in Linux. For more information on how to repair a damaged grub.cfg file in Linux, please search previous articles on 123WORDPRESS.COM or continue browsing the following related articles. We hope that you will continue to support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to Fix File System Errors in Linux Using ‘fsck’
  • Historical Linux image processing and repair solutions
  • A brief discussion on Linux disk repair e2fsck command

<<:  How to use CSS to achieve data hotspot effect

>>:  A brief discussion on the display modes of HTML tags (block-level tags, inline tags, inline block tags)

Recommend

Use of Linux cal command

1. Command Introduction The cal (calendar) comman...

Detailed explanation of JavaScript's Set data structure

Table of contents 1. What is Set 2. Set Construct...

Detailed explanation of mysql.user user table in Mysql

MySQL is a multi-user managed database that can a...

17 excellent web designs carefully crafted by startups

Startups often bring us surprises with their unco...

Analysis and treatment of scroll bars in both HTML and embedded Flash

We often encounter this situation when doing devel...

Solve the group by query problem after upgrading Mysql to 5.7

Find the problem After upgrading MySQL to MySQL 5...

Details of function nesting and closures in js

Table of contents 1. Scope 2. Function return val...

A brief discussion on JS packaging objects

Table of contents Overview definition Instance Me...

Docker data volume container creation and usage analysis

A data volume container is a container specifical...

Common HTML tag writing errors

We better start paying attention, because HTML Po...

A simple LED digital clock implementation method in CSS3

This should be something that many people have do...

Solve the problem of specifying udp port number in docker

When Docker starts a container, it specifies the ...

How to use skeleton screen in vue project

Nowadays, application development is basically se...

MySQL stored procedure in, out and inout parameter examples and summary

Stored Procedures 1. Create a stored procedure an...