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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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 control resource (cgroup) with systemd for user process group in CentOS/RHEL 7
  2. CentOS / RHEL : How to configure a user account to never expire (disable password ageing)
  3. Understanding rsyslog Actions
  4. How to Disable “Predictable Network Interface Device Names” in CentOS/RHEL 7
  5. Extend the Size of /boot Partition on XFS Filesystem (CentOS/RHEL 7)
  6. CentOS / RHEL 7 : How to create custom script to run automatically during boot
  7. How to Compress and Decompress .bz2 files in Linux Using bzip2 Command
  8. How To Customize The Screensaver Options In Gnome on CentOS/RHEL 7
  9. Defining System Jobs Using Cron under Linux
  10. CentOS / RHEL : How to make iptable rules persist across reboots

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable ACPI in CentOS/RHEL 7
  • How to Use real-time query to access data on a physical standby database
  • CentOS/RHEL 8: “ACPI MEMORY OR I/O RESET_REG” Server Hung after reboot
  • How to Create a Physical Standby Database by Using SQL and RMAN Commands
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary