How does CentOs7 fix MBR and GRUB?

How does CentOs7 fix MBR and GRUB?

2019- 06- 16 11:19 Script House Centos

Some friends don’t know how CentOs7 repairs MBR and GRUB; today I will share CentOs7’s method to repair MBR and GRUB; interested friends, let’s take a look.

**1. Repair MBR: **

MBR

( Master Boot Record):

The 0 cylinder, 0 head, and 1 sector of the hard disk are called the master boot sector. Among them, 446Byte is the bootloader, 64Byte is the Partition table, and the remaining 2Byte is the magic number.

Backup MBR:

dd if=/dev/sda of=/root/mbr.bak count=1 bs=512

Destroy the bootloader:

dd if=/dev/zero of=/dev/sda count=1 bs=200

Here, as long as the block size is less than or equal to 446.

**Repair method: **

1、 Use other systems to mount disk repair.

The repair method is similar to the CD-ROM repair, but also uses the grub2-install command.

2、 Repair with the help of the installation CD.

1). Load the CD, select troubleshooting on the CD boot interface:

2). Choose to enter rescue mode:

3). Press Enter to continue:

4). Enter the disk mount selection mode:

The disk will be mounted under /mnt/sysimage/

continue to mount the partition in rw mode.

read only mounts the partition in ro mode.

skip Skip, mount the disk manually in the future.

  1. Select continue, wait a moment, it prompts that the mounting is complete.

  1. The command line to enter rescue mode at this time:

  1. Use the grub2-install command to rebuild the bootloader:

grub2-install root-directory=/mnt/sysimage /dev/sda

No error is displayed, use sync to write to the hard disk, reboot to restart the system.

  1. No error after restarting, grub runs normally:

At this point, the MBR repair is complete.

2. Repair grub

**Grub configuration file is missing: **

After booting, it will directly enter the grub interface, which is displayed as grub>:

The repair steps are as follows:

grub>insmod xfs

grub>set root=(hd0,1)

grub>linux16 /vmlinuz-xxxxx root=/dev/mapper/centos-root

grub>initrd16 /initramfs-.xxxxx.img

After the repair is complete, you can enter the system and rebuild the configuration file.

Note: Because CentOS7 uses grub2, the configuration file has many changes with grub, so remember to back up grub.cfg for recovery.

( adsbygoogle = window.adsbygoogle || []).push({});

Recommended Posts

How does CentOs7 fix MBR and GRUB?
How does python distinguish return and yield
How to install and configure Elasticsearch on CentOS 7
How to install and use Docker on CentOS 7
How to install and configure VNC on CentOS 8
How to install and use Composer on CentOS 8
How to install and configure Redis on CentOS 8
How to install Node.js and npm on CentOS 8
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
How to install and configure phpMyAdmin on CentOS 6
How to install and use Curl on CentOS 8
How to install and configure Owncloud on CentOS 8
How to install and uninstall tomcat on centos
How to install and configure Redmine on CentOS 8
How to add and delete users on CentOS 8
How to install and configure NFS server on CentOS 8
How to install and use Cockpit on CentOS 8/RHEL 8
Install centos7 and connect
Vmware-install and start Centos 8
Vmware-install and start Centos 7
How to install and configure Postfix mail server on CentOS8