• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to recover GRUB (Corrupted boot partition) in CentOS/RHEL 5,6

by admin

The problem

The system is stuck at the grub> prompt as shown below.

recover GRUB CentOS RHEL 5,6

How to recover from such situation.

The solution

When you get above error, in most of the cases you have a corrupted boot partition.

1. To fix the problem execute from grub command line:

grub> find /grub/stage1
find /grub/stage1
(hd0,0)

Above command will look for stage1 (stage1 is placed in MBR and later on its read by the BIOS) this will list where exactly boot partition resident, in this case its hd0,0.

2. Restore boot partition on hd0,0 (first partition on first disk) as in above example from find command.

grub> root (hd0,0)
Filesystem type is ext4fs, partition type 0x83

3. Then setup grub on first disk (hd0) – as in above example boot stage1 is located on hd0.

grub>setup (hd0)

Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 d (hd0) (hd0)1+15 p (hd0,1)/boot/grub/stage
2 /boot/grub/menu.lst"... succeeded
Done.

4. After command will succeed reboot the server.

grub> reboot

Verify if system boot now without any issue.

Further troubleshooting

If issue still persist and again system stops on grub command line verify if grub.conf is present and holds proper values:

grub> find (hd0,0)/grub/grub.conf
find (hd0,0)/grub/grub.conf
(hd0,0)
grub> cat (hd0,0)/grub/grub.conf

cat (hd0,0)/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_lnxovmsan2076-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Oracle Linux Server Unbreakable Enterprise Kernel (3.8.13-16.2.1.el6uek.x86_64)
root (hd0,0)
kernel /vmlinuz-3.8.13-16.2.1.el6uek.x86_64 ro root=/dev/mapper/vg_root-lv_root rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=uk LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg_root/lv_root rd_LVM_LV=vg_root/lv_swap rd_NO_DM rhgb quiet crashkernel=256M@64M
initrd /initramfs-3.8.13-16.2.1.el6uek.x86_64.img

[Hit return to continue]

If issue is spotted with kernel boot params you can manually provide kernel boot strings:

grub> linux /boot/vmlinuz-3.8.13-16.2.1.el6uek.x86_64 ro root=/dev/mapper/vg_root-lv_root rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=uk

grub> boot

If that won’t help or for example grub.conf file is missing or while running cat on grub.conf getting for example below output:

grub> cat (hd0,0)/grub/grub.conf

cat (hd0,0)/grub/grub.conf
????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????

It will be necessary to boot system to Rescue Mode and verify what is going on – above output with ‘???’ indicate corruption of root-fs. If grub is still not working even after restoring grub.conf file and still getting grub errors around boot image it will be necessary to reinstall the system.

For UEFI boot only

To restore Grub in UEFI boot execute below command:

# efibootmgr -v

Afterwards run: grub-install

# grub-install /dev/sda

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, Linux

Some more articles you might also be interested in …

  1. How to Change the Default Shell In Linux
  2. fwupdmgr: command not found
  3. pacaur Command Examples in Linux
  4. CentOS / RHEL : How to disable ssh for non-root users (allowing ssh only for root user)
  5. modprobe: command not found
  6. CentOS / RHEL 6 : Install and Configure SNMPv3
  7. How to List and Set SELinux Context for MySQL Server
  8. “btrfs” command examples to Create and Manage Btrfs File System
  9. ping: command not found
  10. How to Replace a Failed Btrfs Device

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright