Linux Grub repair in CentOS 6.5

Source: Internet
Author: User
Tags uuid

In the process of using Linux, it is inevitable that the boot prompt grub > can not start, may be the system/boot/grub file loss and other causes, when this problem occurs as long as the system partition is not formatted generally can be repaired, the following virtual machine as an example, delete/ boot partition, re-fixed in linux rescue mode:

The system used for the experiment is CentOS 6.5 x86_64

1. Remove boot partition: Causes the Gurb and Linu cores to be lost and then restarted:

At this point, after the system restart is completely unable to start again, as follows:

2. Use the disc image to boot the system and select rescue mode to start:

Tip To mount the system to/mnt/sysimage:

2. Switch the root to the previous system:

3. Create a CD-ROM mount directory and mount the disc:

4, install Kerner Package, will generate/boo directory and kernel and INITRAMFS

5. To fix grub, first check your disk partition to confirm that grub is installed on that disk:

To install the Grub boot for the first disk:

6. Confirm that the Geub directory has been generated:

At this point the system still does not start normally, because confirm grub.conf file, can try to reboot to look at the interface:

5, in the Grub interface to specify kernel and Initramfs where the path is started, the commands can be manipulated are:

Grub>kernel kernel file//set path to kernel file

GRUB>INITRD image file name//Set Mirror path

Grub>boot//Start the specified operating system

Grub>help//Get Help

Grub>reboot//Restart System

Grub>md5-crypt//Generate password for MD5 ciphertext

Grub>setup (Hdx[,y])//install gurb to mbr/the boot sector of the specified partition

Grub>hide partition//Hide partition

Grub>cat filename//Display file contents

Grub>find file name//Find Files

Grub>rootnoveify (Hdx,y)//sets the partition for the root device, but does not check the mount point

Grub>chainloader filename//loading the specified file

Specify the Linux kernel and Initramfs file path here and start the Linux system:

Note:

grub> root (hd0,1) #是说跟分区在第一块硬盘的第二个分区

grub> kernel/boot/vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/sda2 #指明内核路径和根分区

Grub> initrd/boot/initramfs-2.6.32-431.el6.x86_64.img #指明initramfs路径启动系统加载驱动

grub> boot #启动上面指定的系统, if the reboot is the same as restarting the entire system, just the setup has failed

Now you can boot the system, but there is no grub.conf file, you can write a grub.conf file after the system startup

6. Write grub.conf file:

You can see that at this time the system does not have a grub.conf file, if you restart the system will not be able to boot normally, unless the Grub interface specifies the path of the kernel and driver files:

To create a grub.conf file:

Note: Kernel a line behind root=/dev/sda2 refers to the disk where the root partition resides, if the boot partition and the root partition are not together, The grub.conf file to indicate the boot partition and the root partition, the other is not recommended to install the disk partition to write the path of the root partition, because it is possible to change the disk after the system restarts, it is recommended to use UUID means that each partition has its own UUID, is the only identity in the entire system, you can use command blk Id/dev/sda2 get.

7, finally restart the system to the hard disk directly start the test;

The system has started to complete normally!

Summary: Repair grub is a long process, the afternoon spent three hours to write blog and repair system, repair during the error, the virtual machine restarted at least dozens of times, so to have patience, serious to do one thing, to do the best!

Linux Grub repair in CentOS 6.5

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.