How to fix Grub Rescue in CentOS
Symptoms:
Boot display:
GRUB loadingerror:unknow filesystemgrub rescue>
Cause:
The following operations have been found to cause this problem:
1. To delete debian, delete/format the partition where debian is located in windows.
2. Adjust the disk and use tools to merge, split, adjust, and delete partitions to change the number of disk partitions.
3. reinstall the system and install linux to a new partition. The original partition has been formatted, but grub2 has not been re-installed.
4. Use the debian backup tool or derivative version manufacturing tool to restore the primary partition to the old version of 8. X. As a result, grub of the old version is grub1, and grub2 is destroyed.
Generally, the operator does not know that grub2 is divided into two parts, one part (generally) written on mbr, the other part is written in the/boot/grub directory of a partition (if/boot is separately partitioned, it is directly written in the/grub directory of the corresponding partition. As a result, the part in the mbr of grub2 cannot find the part in the/grub directory (or the part has been deleted ).
Ideas:
Method 1: Delete grub2 permanently so that the prompt does not appear again:
This method is applicable to users who no longer want to use debian and want to switch back to Windows.
This is very simple, as long as you have a Windows boot disk (not a Ghost), use it to start, to select the installation location, do not actually install, exit and restart it.
You can also use it to start to the fault recovery platform and run fixboot or fixmbr.
Run the following command in the win7 command line:
BootRec.exe /fixmbr
(/Fixmbr repair mbr,/FixBoot repair startup sector,/ScanOs detection installed win7,/RebuildBcd reconstruction bcd .)
Method 2: reinstall and fix grub2
1. Run the ls command to find the partition where Ubuntu is installed:
Run the following command under grub rescue>:
ls
All disk partition information is listed, for example:
Reference:
(Hd0, 1), (hd0, 5), (hd0, 3), (hd0, 2) Note: I am (hd0), (hd0, msdos3 ), (hd0, msdos5)
2. Call the following commands in sequence: X indicates the number of each partition.
If/boot is not partitioned separately, run the following command:
ls (hd0,X)/boot/grub
If/boot is partitioned separately, run the following command:
ls (hd0,X)/grub
3. Under normal circumstances, hundreds of files will be listed. Many files have extensions:. mod,. lst, And. img. Another file is grub. cfg. If the file in the folder is displayed (hd0, 5), it indicates that Linux is installed in this partition.
4. If the correct grub directory is found, try to temporarily associate the two parts of grub as follows:
The following command does not have a separate partition for/boot:
grub rescue>set root=(hd0,5)grub rescue>set prefix=(hd0,5)/boot/grubgrub rescue>insmod /boot/grub/normal.mod
The command for separate partitioning of/boot is as follows: (these statements need to be verified)
grub rescue>set root=(hd0,5)grub rescue>set prefix=(hd0,5)/grubgrub rescue>insmod /grub/normal.mod
Then, call the following command to display the lost grub menu.
grub rescue>normal
But don't be happy. If the problem persists during the restart, we need to go to Linux and fix grub.
Start up. After Entering debian, run the following command on the terminal:
sudo update-grubsudo grub-install /dev/sda
(Sda is your hard disk number. do not specify a partition number, such as sda1 or sda5)
Have the grub Startup Menu been restored? Congratulations! recovery successful!
5. If the correct/grub directory cannot be found, for example, 3rd or 4 misoperations, try to find whether the linux core file exists. Then, call the following command in sequence: X indicates the number of each partition:
Grub rescue>, enter:
If/boot is not partitioned separately:
ls (hd0,X)/boot
If/boot is partitioned separately, then:
ls (hd0,X)
Find a file named like a vmlinuz-3.0.0-12-generic, which is the linux core file, if found, write down the value of X in (hd0, X. Assume that the files in the folder are displayed when (hd0, 5) is found.
Start with live cd or live usb, and input the following commands in sequence on the ubuntu terminal of live cd ("5" in sda5 must be changed to the value recorded above) (These two sentences need to be verified ):
If/boot is not partitioned separately:
sudo mount /dev/sda5 /mntsudo grub-install --boot-directory=/mnt/boot /dev/sda
If/boot is partitioned separately, then:
sudo mount /dev/sda5 /mntsudo grub-install --boot-directory=/mnt /dev/sda
Then restart.
(The above two commands can also solve the problem that the grub installation location is incorrect during debian installation, and grub is not installed in/dev/sda. As a result, the debian startup item does not directly go to windows during startup, however, you need to determine the number of "5" in sda5 .)
6. If you do not have a linux core file, reinstall it.