Article Title: Restore the GRUB boot program of the Linux operating system. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The example version used in this article is MagicLinux 1.2 final. Due to Windows reinstallation and other misoperations, the GRUB boot program installed in MBR cannot boot the system any more, and thus the Linux system cannot be accessed. There are many ways to solve this problem on the Internet, but it won't work after the test by the author. Finally, combined with multiple articles on the internet, grub of ML1.2 is successfully restored after being overwritten by WinXP, write down my experiment experience.
The author installed ML1.2 on/dev/hda11, corresponding to the location of grub (hd0, 10). Note that the partition numbers expressed in the/dev/hdax method start from 1, therefore, in grub, 1 is subtracted. Grub is installed in MBR. After WinXP is installed, it cannot enter linux. Although ML1.2 is used as an example, grub of the latest version is universal. MagicLinux 1.2 final uses grub version 0.95.
First use a Repair Disk to enter grub, or use other linux recovery disks to enter the linux system, and then enter the grub console. In short, you just need to try your best to enter a console. Then prepare to boot to the Linux system on the hard disk. As follows:
Grub> root (hd0, 10)
Grub & gt; kernel/boot/vmlinuz-2.6.9 init 5 ro root =/dev/hda11
Grub> initrd/boot/initrd-2.6.9.img
Grub> boot
The above is the repair method after you use the Repair Disk to enter grub. You can enter other console repair methods temporarily. In the above process, you can access the linux System text message on the hard disk. Then begin the repair process.
# Grub
Grub> root (hd0, 10)
Grub> setup (hd0)
Grub> quit
# Grub-install hd0
Grub will be installed to MBR in a mountain step, which cannot be missing in any step. If the grub-install step is missing, grub is installed to MBR, but the system menu is not displayed.
In addition, MagicLinux1.2final will prompt that grub cannot be found in the last step. This is because grub-install is a shell script that uses absolute paths to find grub programs. The default grub search path is/usr/sbin/grub, but ML1.2 is in/sbin/grub. Therefore, you only need to execute the following statement and copy it:
# Cp/sbin/grub/usr/sbin/grub
In this way, grub can be correctly restored to MBR.
This article does not directly write a birthday text message on the console to fix grub because many CD releases contain a small number of/dev/hdax files, I have a maximum of/dev/hda8 in my hand, so I can't access/dev/hda11 at all, so I have to give up. In addition, even the CD release requires grub boot. Press the "C" Key To Go To The grub console and enter the command to go to Linux on the hard disk.
Finally, we recommend that you back up the MBR and use the following command in linux:
# Dd if =/dev/hda of =/root/linux. bin bs = 512 count = 1
Note that if =/dev/hda is used to back up data in MBR. if grub is installed in a specific partition, You have to select it. After the backup, the linux. binfile can be copied to Windows, backup one copy, and copy the other copy to the C root directory. Modify the boot. ini file and add the following line:
C: \ linux. bin = "Linux"
In this way, you can use the Windows NT loader to guide the linux system. It will be more convenient to restore and repair linux in the future.