RHEL: Reinstalling Boot Loader on the Master Boot Record (MBR)

# Tested on RHEL 5 & 6

# In many cases, the GRUB boot loader can mistakenly be deleted, corrupted or replaced.
# We can manually reinstall GRUB on the master boot record, using either "grub-install"
# or the "grub" prompt.

# Ensure the device.map file located in the /boot/grub directory lists all boot devices
# in the same order detected by system ROM.

# grub-install -----------------------------------------------------------------------------

cat device.map
   # this device map was generated by anaconda
   (hd0)     /dev/cciss/c0d0

# Use the 'grub-install' command pointing to the root device.

grub-install /dev/cciss/c0d0


#  --- OR ---


# "grub" utility ---------------------------------------------------------------------------

# Manually set up the MBR and /boot partition from the grub prompt. (hd0) and (hd0,0) should
# coincide with the results from the "find" command. It may be that "find" command will
# fail showing an error message; if that's the case we can continue with the procedure as
# "find" step is not mandatory

grub
   grub> find /boot/grub/stage1
   grub> root (hd0,0)
   grub> setup (hd0)

# ------------------------------------------------------------------------------------------


# If a crash occurred on the server and GRUB boot loader was lost, this may be recovered by
# booting from a rescue CD.

# After the command prompt is displayed, change the root directory to the OS installation
# by typing this command:

chroot </mnt/sysimage>

# Review the /boot/grub/grub.conf file, as additional entries may be needed for GRUB to control
# additional operating systems.

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
How to accurately determine when the system was booted
Viewed 1321 times since Wed, Oct 3, 2018
How To: Linux Hard Disk Encryption With LUKS [ cryptsetup Command ]
Viewed 5770 times since Fri, Jul 13, 2018
Linux: Disks diagnostic using smartctl
Viewed 12262 times since Wed, Jul 25, 2018
Use inotify-tools on CentOS 7 or RHEL 7 to watch files and directories for events
Viewed 11787 times since Fri, Jul 27, 2018
How To Run Multiple SSH Command On Remote Machine And Exit Safely
Viewed 1469 times since Tue, Aug 6, 2019
debian Install a newer kernel in Debian 9 (stretch) stable
Viewed 903 times since Sun, Sep 23, 2018
Creating SWAP partition using FDISK & FALLOCATE commands
Viewed 1149 times since Thu, Jan 16, 2020
Linux RedHat How To Create An RPM Package
Viewed 50 times since Sun, Jan 9, 2022
Linux Cluster Tutorial
Viewed 927 times since Sat, Sep 29, 2018
watchdog How to restart a process out of crontab on a Linux/Unix
Viewed 4063 times since Tue, Jul 31, 2018