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

UnixArena

  • Home
  • kubernetes
  • DevOps
    • Terraform
    • Jenkins
    • Docker
    • Openshift
      • OKD
    • Ansible engine
    • Ansible Tower
      • AWX
    • Puppet
  • Cloud
    • Azure
    • AWS
    • Openstack
    • Docker
  • VMware
    • vCloud Director
    • VMware-Guests
    • Vcenter Appliance 5.5
    • vC OPS
    • VMware SDDC
    • VMware vSphere 5.x
      • vSphere Network
      • vSphere DS
      • vShield Suite
    • VMware vSphere 6.0
    • VSAN
    • VMware Free Tools
  • Backup
    • Vembu BDR
    • Veeam
    • Nakivo
    • Azure Backup
    • Altaro VMBackup
    • Spinbackup
  • Tutorials
    • Openstack Tutorial
    • Openstack Beginner’s Guide
    • VXVM-Training
    • ZFS-Tutorials
    • NetApp cDot
    • LVM
    • Cisco UCS
    • LDOM
    • Oracle VM for x86
  • Linux
    • How to Articles
    • Q&A
    • Networking
    • RHEL7
  • DevOps Instructor-led Training
  • Contact

How to Recover GRUB on RHEL 7 / CentOS 7 ?

May 31, 2018 By Cloud_Devops 6 Comments

This article will provide the step by step procedure to recover the GRUB on REHL 7 / CentOS 7. GRUB corruption / lost is one of the most common issues on Linux servers/workstations. The possible reasons for grub corruption could be due to bad disk/bug on the firmware or powered off the system abruptly. Systems ships with BIOS/ UEFI firmware and you should know what OS is using currently. Here is the way to identify BIOS vs UEFI on Linux servers.  To recover GRUB on RHEL7 /CentOS 7, you must have the latest DVD or ISO image.

 

Common Errors in GRUB:

If GRUB is corrupted or lost, the system will not boot and it will be stuck in grub like below.

GNU GRUB version 0.97 (638K lower / 3143616K uper memory)

[ Minimal BASH-like line editing is supported. For the first word. TAB
lists possible command completions. Anywhere else TAB lists the possible 
completions of a device/filename.]

grub>

The system gets stop with the following message.

GRUB loading stage 2

 

In such cases, Please follow the below instructions.

Recover/Restore the GRUB – BIOS Based system:

1. Insert RHEL 7 / CentOS 7 latest DVD on the server or attach ISO image using ILO.
2. In case of a Virtual machine, attach the ISO image to the VM.
3. Boot the server using the DVD/ISO image.

4. Choose troubleshooting option once the system is booted in DVD/ISO.

RHEL7 CentOS7 - Troubleshooting Rescue Mode
RHEL7 CentOS7 – Troubleshooting Rescue Mode

 

5. Choose the rescue mode.

RHEL 7 - Rescue Mode
RHEL 7 – Rescue Mode

 

6. Press 1 to continue to find the OS image and get the shell prompt.

Continue - Rescue Mode - RHEL
Continue – Rescue Mode – RHEL

 

7.chroot to the OS image.

chroot to OS Image - RHEL
chroot to OS Image – RHEL

 

8. Starting RHEL 7/CentOS 7,  GRUB 2 is the default  bootloader. The GRUB 2 configuration file is /boot/grub2/grub.cfg. Install grub boot loader on root disk. (Default : /dev/sda).

grub2-install - RHEL 7 CentOS7
grub2-install – RHEL 7 CentOS7

 

9. Navigate to /boot/grub2 directory and confirm the existence of “grub.cfg” .  Here “grub.cfg” file is not exists.

grub.cfg is missing - RHEL 7
grub.cfg is missing – RHEL 7

 

10. Let’s generate “grub.cfg”  file.

grub2-mkconfig - Recreate grub.cfg
grub2-mkconfig – Recreate grub.cfg

If you are missing grub2-mkconfig command, install “grub2-tools.x86_64” package in rescue mode . Since you have booted from DVD, the package should be available in that.

Grub.cfg recreated using grub2-mkconfig

Grub.cfg recreated using grub2-mkconfig

 

11. Exit from the chroot and reboot the system.

This will work only on BIOS-based X86 servers and virtual machines but will not work with UEFI firmware servers and VMs.

Here is the link to identify that what firmware type was used to boot the system.

Filed Under: CentOS, Redhat-LINUX, RHEL7 Tagged With: CentOS, RHEL7

Reader Interactions

Comments

  1. Andrzej says

    March 18, 2024 at 2:29 pm

    Thank you. It just worked based on this precised description.
    It saved me a lot of time and trouble. In my case the grub.cfg got broken during the update. Installation of the firmware package caused together with grub2 update truncated the grub.cfg to the size of 0.

    Reply
  2. mallek says

    June 18, 2022 at 4:07 am

    thanks it was very helpfull my virtual box died by mistake and i am able to rapire it

    best regards
    Mallek

    Reply
  3. Sourav says

    June 24, 2021 at 1:37 am

    Even if you go to rescue despite all well in your system, you wont find grub.cfg in /boot/grub2. Infact grub2 itself wont be visible and will not be shown as present. So there is no need to recreate grub.cfg using grub2-mkconfig

    Reply
  4. Adnan says

    October 15, 2019 at 2:36 am

    Hi I tried the tutorial listed (all the steps you listed ) but when I reboot I get the same results , any help please !

    Reply
  5. Gary says

    July 9, 2019 at 4:46 am

    You saved my butt…thank you. I had a weird scenario where I had to restore a CentOS server to a smaller drive. I appreciate this.

    Reply
  6. Vasya says

    September 29, 2018 at 6:04 pm

    Thanks, you really help me! You save me 100+ hours work time.

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Follow UnixArena

  • Facebook
  • LinkedIn
  • Twitter

Copyright © 2025 · UnixArena ·

Go to mobile version