Repairing a Damaged GRUB with CentOS 5 |
Server Training - Ubuntu Server Administration |
Repairing a Damaged GRUB with CentOS 5 GRUB, the Grand Unified Bootloader, is usually quite dependable. But, like everything else in life, it isn't perfect. Once in a blue moon, it may give you some problems. Recently, , we used YUM Extender to update one of our CentOS 5 machines to CentOS 5.1. The update included a new kernel, which meant that the GRUB configuration had to be re-written. Usually, that goes without a hitch. This time, though, was different. When the update completed, we rebooted the machine so that we could use the new kernel. But, when it got to the point where we should have seen the GRUB splash screen, all we got was a completely black screen with the single word "GRUB". At that point, the boot-up process stopped dead in its tracks. Apparently, the update didn't update GRUB correctly. To see what the problem was, we booted the machine from the CentOS 5 installation DVD. At the opening menu, we pressed the F2 key to get to the options menu. There, we typed in "linux rescue". After answering the setup screens, and choosing "No" when asked if we wanted to set up networking, we arrived at the command prompt. If you ever get the chance to do this, pay close attention to the screens leading up to the command prompt. The last one tells you what you need to do next. (That is, in case you don't remember from this article.) At the command prompt, enter: chroot /mnt/sysimage
Now, we've mounted the hard drive's filesystem, and we can do whatever we need to with it. Next, let's cd to the GRUB directory, and take a look at the menu.lst file. cd /boot/grub less menu.lst
You should see something like: # grub.conf generated by anaconda
Entries for both the new kernel and the old one are there, so this apparently isn't the problem. We also cd'ed back to the /boot directory, and verified that all of the proper kernel files were there.
The only possibility left is that the new GRUB configuration just didn't get written to the hard drive's Master Boot Record. To test our theory, we tried running the "grub-install' utility. For this, we entered the "grub-install" command, followed by the device on which we wanted to install it. In this case, we needed to install it on the first hard drive: grub-install hd0
When it completed, enter "exit" twice to reboot the machine, and removed the installation DVD. It worked like a champ, problem resolved.
For more information, enter "info grub" and "info grub-install" at the command-line of your Linux machine. |