CentOS 7 repair MBR and grub

Source: Internet
Author: User

Reproduced

First, repair MBR:

MBR (master boot record main boot recording):

The hard disk's 0 cylinders, 0 heads, and 1 sectors are referred to as the primary boot sector. Where 446Byte is bootloader,64byte for partition table, and the remaining 2Byte is magic number.

Backup MBR:

#dd IF=/DEV/SDA Of=/root/mbr.bak count=1 bs=512

Destroy Bootloader:

#dd If=/dev/zero OF=/DEV/SDA count=1 bs=200

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

Repair method:

1. Mount disk repair with other systems.

The repair method is similar to the disc repair and is also used with the Grub2-install command.

2. Repair with the installation CD.

1. Mount the disc and select Troubleshooting on the disc Boot interface:

2. Select Enter Rescue mode:

3. Press ENTER to continue:

4. Enter the disk Mount selection mode:

The disks will be mounted to the/mnt/sysimage/

Continue mount the partition in RW mode.

Read only mounts the partition in RO mode.

Skip skips, and in the future, manually mount the disks yourself.

5. Select continue, wait a moment, prompt has been mounted complete.

6. Enter the rescue mode command line at this point:

7. Rebuild the bootloader using the Grub2-install command:

#grub2-install ROOT-DIRECTORY=/MNT/SYSIMAGE/DEV/SDA

show no errors, use sync to write to the hard drive, reboot restart the system.

8. No error after reboot, GRUB is running normally:

At this point, the MBR repair is complete.

Second, repair grub

Grub configuration file is missing:

Boot will be directly into the grub interface, 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

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

Note: CentOS7 because of the use of GRUB2, configuration files and grub have a lot of changes, be sure to remember to backup grub.cfg for recovery.

CentOS 7 repair MBR and grub

Related Article

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.