CentOS7 Repairing MBR and Grub

Source: Internet
Author: User


CENTOS7 Repairing MBR and Grub


First, repair MBR:

MBR (masterboot 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=512


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:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5A/5D/wKioL1T7IZrSXiEQAACRYsiJ8xM320.jpg "style=" Font-family:sans-serif; "/>

2. Select Enter Rescue mode:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/5D/wKioL1T7IZuBmuQNAADnBYyvDVk934.jpg "/>

3. Press ENTER to continue:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/61/wKiom1T7IILSEMZzAAAkJYZYNg0861.jpg "/>

4. Enter the disk Mount selection mode:

                  disk will be mounted to/mnt/sysimage/under

            1. continue mount the partition in RW mode.

            2. read only mounts partitions in RO mode.

            3. skip Skip and manually mount the disk in the future.

              650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M00/5A/ 5d/wkiol1t7izuqnsrpaafts_0exgk226.jpg "/>

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

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5A/61/wKiom1T7IIPgTzx_AADXMemXSzk892.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/5D/wKioL1T7IZyAqzNZAABUgDYdgUo338.jpg "/>

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

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/61/wKiom1T7IIOSAvKkAACDJSnhXHA608.jpg "/>

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

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

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/5D/wKioL1T7IZ2gt6NCAABy0qeho54335.jpg "/>

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

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

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5A/61/wKiom1T7IITD7PkdAAA8qXx_ulU530.jpg "/>

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>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/61/wKiom1T7IITgkxQPAABdY43s4NM338.jpg "/>

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

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5A/5D/wKioL1T7IZ7Q-uDsAAEms6WlQtc284.jpg "/>

This article is from "Small Private blog" blog, please be sure to keep this source http://ggvylf.blog.51cto.com/784661/1618345

CentOS7 Repairing MBR and Grub

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.