Learn how to repair GRUB bootloader in CentOS 8 with our step-by-step guide. Troubleshoot boot issues and restore your system’s functionality easily. #centlinux #linux #grub
Table of Contents
What is GRUB?
GRUB (GRand Unified Bootloader) 2 is part of GNU Project and the default bootloader for famous Linux distros like RHEL, CentOS, Ubuntu, etc. GRUB is the first software program that runs when a computer is started. GRUB is responsible for loading the Kernel software. The Kernel then initializes the rest of the operating system.
GRUB (Grand Unified Bootloader) is a crucial component in the boot process of many Unix-like operating systems, including Linux distributions. It is responsible for loading the kernel of the operating system and transferring control to it, thus starting the OS.
Key features and functionalities of GRUB include:
- Multi-boot Support: GRUB can manage and boot multiple operating systems installed on a single machine. This is particularly useful for users who run dual-boot or multi-boot setups.
- Configurable and Customizable: GRUB configuration can be easily customized through a configuration file, usually located at
/boot/grub/grub.cfg
. Users can modify boot entries, set default operating systems, and change timeout values. - Command Line Interface: GRUB provides a command line interface (CLI) that allows users to manually enter boot commands, debug issues, and test configurations without modifying the boot configuration file.
- Graphical Menu Interface: GRUB offers a graphical menu interface that lists all available operating systems and kernel versions, making it easy for users to select their desired boot option.
- Filesystem Support: GRUB can read from a wide range of filesystems including ext2/3/4, Btrfs, XFS, JFS, ReiserFS, and even FAT and NTFS. This allows it to load kernels and other files from different types of partitions.
- Network Booting: GRUB supports booting from network locations using protocols like TFTP. This is useful for diskless systems and network installations.
- Security Features: GRUB can be configured with password protection to restrict unauthorized access to its configuration and boot entries. This adds a layer of security to the boot process.
- Advanced Scripting: GRUB scripting language allows for the creation of complex boot scripts, which can automate various boot tasks and provide advanced boot capabilities.
Understanding and managing GRUB is essential for system administrators and power users, as it directly impacts the bootability and flexibility of the operating system. Problems with GRUB, such as corrupted configurations or missing bootloader files, can prevent a system from starting, making GRUB troubleshooting skills valuable for maintaining system uptime and stability.

Problem Statement
There are situations in which GRUB bootloader is corrupted. In such scenarios, System Administrators have to repair GRUB bootloader.
In this article, we are discussing the following four scenarios and how to repair GRUB bootloader in CentOS 8.
- The GRUB menu i.e. grub.cfg is corrupted or missing.
- The CentOS 8 Kernel i.e. vmlinuz-4.x is corrupted or missing.
- The CentOS 8 initrd i.e. initramfs-4.x is corrupted or missing.
- The /boot directory is corrupted or missing.
Recommended Training: Complete Linux Training Course to Get Your Dream IT Job 2025 from Imran Afzal

Linux Server Specification
We have provisioned virtual machine with minimally installed CentOS 8 operating system with following specification.
- CPU – 3.4 Ghz (2 cores)
- Memory – 1 GB
- Storage – 20 GB
- Operating System – CentOS Linux 8.0
- Hostname – grub-recovery-01.recipes.com
- IP Address – 192.168.116.206 /24
Replacement for 65W Lenovo Laptop Charger USB C ;Compatible with Lenovo ThinkPad T480s T580s T490 E480 E580 Chromebook C330 S330 100e 300e 500e,Yoga C930 C940 720 Power Supply Adapter Cord
$9.99 (as of April 18, 2025 16:01 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)How to Repair grub.cfg in CentOS 8
Connect with grub-recovery-01.recipes.com using ssh as root user.
To produce this recovery scenario, we are deleting the grub.cfg file.
[root@grub-recovery-01 ~]# rm -f /boot/grub2/grub.cfg
Your system will continue to perform smoothly, unless you restart it and it will then unable to find the grub.cfg file and it will failed to boot Linux operating system.
Reboot the system now.
[root@grub-recovery-01 ~]# systemctl reboot
The machine will now boot into GRUB prompt because of the missing grub.cfg file.
Minimal BASH-like line editing is supported. For the first word,
TAB lists possible command completions. Anywhere else TAB lists
possible device or file completions.
grub>
Restart the system and boot using CentOS 8 ISO/DVD to repair grub.cfg.

At the CentOS 8 installation menu, select Troubleshooting and press <ENTER>.

Select Rescue a CentOS Linux system and press <ENTER>.

It will ask you for mounting your filesystem, choose the option and ‘1’ and press <ENTER>.
Press <ENTER> again to acquire a shell.
Execute chroot command to access your filesystem.
sh-4.4# chroot /mnt/sysimage
By using grub2-mkconfig command, you can regenerate grub.cfg file.
bash-4.4# grub2-mkconfig -o /boot/grub2/grub.cfg
If you are working on an UEFI based machine then you have to generate grub.cfg file in /boot/efi/EFI/centos/ directory.
If you are using SELinux, then create following file to trigger SELinux file relabeling process on next startup.
bash-4.4# touch /.autorelabel
Finally exit from chrooted environment and reboot your system.
bash-4.4# exit
sh-4.4# reboot
Boot from your Hard Disk.
If you have repair grub.cfg file by following the above steps correctly, then it will now display the GRUB boot menu.

We have successfully recovered grub.cfg file on CentOS 8.
How to Repair vmlinuz in CentOS 8
Connect with grub-recovery-01.recipes.com using ssh as root user.
To produce this recovery scenario, we are removing the vmlinuz-4.18.0-80.el8.x86_64 file.
[root@grub-recovery-01 ~]# rm -f /boot/vmlinuz-4.18.0-80.el8.x86_64
Reboot the system.
[root@grub-recovery-01 ~]# systemctl reboot
On boot, GRUB will display the following warning and unable to load Kernel file.
error: ../../grub-core/fs/fshelp.c:258:file '/vmlinuz-4.18.0-80.el8.x86_64' not
found.
error: ../../grub-core/loader/i386/pc/linux.c:413:you need to load the kernel
first.
Press any key to continue...
Restart your system and boot using CentOS 8 ISO/DVD to repair vmlinuz.

At the CentOS 8 installation menu, select Troubleshooting and press <ENTER>.

Select Rescue a CentOS Linux system and press <ENTER>.

It will ask you for mounting your filesystem, choose the option and ‘1’ and press <ENTER>.
Press <ENTER> again to acquire a shell.
Go to Packages directory in ISO/DVD.
sh-4.4# cd /mnt/install/repo/BaseOS/Packages
Reinstall CentOS 8 Kernel using following command.
sh-4.4# rpm -ivh --root=/mnt/sysimage --replacepkgs kernel-core-4.18.0-80.el8.x86_64.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:kernel-core-4.18.0-80.el8 ################################# [100%]
Verify that vmlinuz-4.x file is created by the installer.
sh-4.4# ls /mnt/sysimage/boot/vmlinuz*
/mnt/sysimage/boot/vmlinuz-0-rescue-9239012f800e401d86d70eef6bc4f8b6
/mnt/sysimage/boot/vmlinuz-4.18.0-80.el8.x86_64
If you are using SELinux then create following file to trigger SELinux file relabeling process on next startup.
sh-4.4# touch /mnt/sysimage/.autorelabel
Reboot the system now.
sh-4.4# reboot
The GRUB will be able to load the Kernel now and you will reach at the login prompt after successful startup.
CentOS Linux 8 (Core)
Kernel 4.18.0-80.el8.x86_64 on an x86_64
grub-recovery-01 login:
We have successfully recovered CentOS 8 Kernel.
Wireless Gaming Headset for PC, Ps5, Ps4, 2.4 Ghz USB & Type-C Gaming Headphones with Microphone, 30H Battery Bluetooth Headphones for Switch, Laptop, Mobile, Mac
$26.99 (as of April 17, 2025 16:01 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)How to Repair initrd in CentOS 8
Connect with grub-recovery-01.recipes.com using ssh as root user.
To initiate this recovery scenario, we are removing the initramfs-4.18.0-80.el8.x86_64.img file.
[root@grub-recovery-01 ~]# rm -f /boot/initramfs-4.18.0-80.el8.x86_64.img
Reboot your system.
[root@grub-recovery-01 ~]# systemctl reboot
After reboot the GRUB will display following warning and unable to find initramfs-4.x file.
error: ../../grub-core/fs/fshelp.c:258:file
'/initramfs-4.18.0-80.el8.x86_64.img' not
found.
Press any key to continue...
Restart the system and boot using CentOS 8 ISO/DVD to repair initrd.

At the CentOS 8 installation menu, select Troubleshooting and press <ENTER>.

Select Rescue a CentOS Linux system and press <ENTER>.

It will ask you for mounting your filesystem, choose the option and ‘1’ and press <ENTER>.
Press <ENTER> again to acquire a shell.
Execute chroot command to access our filesystem.
sh-4.4# chroot /mnt/sysimage
Use dracut command to recreate initramfs-4.x file.
bash-4.4# dracut
Verify that initramfs-4.x file is created by dracut command.
bash-4.4# ls /boot/initramfs-*
/boot/initramfs-0-rescue-9239012f800e401d86d70eef6bc4f8b6.img
/boot/initramfs-4.18.0-80.el8.x86_64.img
Exit chroot and reboot the system now.
bash-4.4# exit
sh-4.4# reboot
If you have successfully repair initrd, the GRUB will be able to load the initrd image now and you will reach at the login prompt after successful startup.
CentOS Linux 8 (Core)
Kernel 4.18.0-80.el8.x86_64 on an x86_64
grub-recovery-01 login:
CentOS 8 initrd image has been repaired.
How to Repair boot Partition in CentOS 8
Connect with grub-recovery-01.recipes.com using ssh as root user.
To initiate this recovery scenario, we are removing /boot directory.
[root@grub-recovery-01 ~]# rm -rf /boot/*
Reboot your system.
[root@grub-recovery-01 ~]# systemctl reboot
After reboot the GRUB will show the “grub rescue” prompt.
.
error: ../../grub-core/fs/fshelp.c:258:file '/grub2/i386-pc/normal.mod' not foun
d.
Entering rescue mode...
grub rescue>
Restart the system and boot using CentOS 8 ISO/DVD to repair boot partition.

At the CentOS 8 installation menu, select Troubleshooting and press <ENTER>.

Select Rescue a CentOS Linux system and press <ENTER>.

It will ask you for mounting your filesystem, choose the option and ‘1’ and press <ENTER>.
Press <ENTER> again to acquire a shell.
The CentOS 8 DVD/ISO is mounted in mnt directory.
Go to BaseOS packages directory.
sh-4.4# cd /mnt/install/repo/BaseOS/Packages
Reinstall kernel-core package using following command.
sh-4.4# rpm -ivh --root=/mnt/sysimage --replacepkgs kernel-core-4.18.0-80.el8.x86_64.rpm
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:kernel-core-4.18.0-80.el8 ################################# [100%]
grub2-editenv: error: cannot open '/boot/grub2/grubenv.new': No such file or directory.
Ignore above error, we will create this file manually.
Run chroot to mount /mnt/sysimage as root directory.
sh-4.4# chroot /mnt/sysimage
Reinstall GRUB 2 using following command.
bash-4.4# grub2-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
Recreate grub.cfg (GRUB menu) using grub2-mkconfig command.
bash-4.4# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done
If you are using SELinux, then create following file to trigger SELinux file relabeling process on next startup.
bash-4.4# touch /.autorelabel
Finally exit from chrooted environment and reboot your system.
bash-4.4# exit
sh-4.4# reboot
Boot using your Hard Disk and now it will display the GRUB boot menu this time.

We have successfully repair boot partition on CentOS 8.
Practical Linux Forensics: A Guide for Digital Investigators
$41.91 (as of April 17, 2025 16:01 GMT +00:00 – More infoProduct prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on [relevant Amazon Site(s), as applicable] at the time of purchase will apply to the purchase of this product.)Final Thoughts
Repairing the GRUB bootloader in CentOS 8 can be a complex but essential task to restore your system’s functionality. By following the right steps and using the appropriate tools, you can troubleshoot and fix common boot issues. Whether you’re a seasoned system administrator or a beginner, having a solid understanding of GRUB Bootloader and its repair process is crucial for maintaining your system’s health.
Whether you need cloud optimization, server management, or automation, I provide comprehensive AWS and Linux services. Hire me on Fiverr to elevate your systems.
FAQs
1. What is GRUB bootloader in CentOS 8?
GRUB (Grand Unified Bootloader) is the primary bootloader used in CentOS 8. It loads the operating system into memory and allows users to choose between different kernels or operating systems during boot.
2. What causes GRUB bootloader failure in CentOS 8?
GRUB failure can occur due to incorrect updates, accidental deletion, disk corruption, BIOS/UEFI misconfiguration, or improper partition modifications.
3. How can I tell if GRUB is corrupted?
If GRUB is corrupted, you may encounter errors like “grub rescue>” or “no such partition”, or the system may fail to boot into CentOS 8.
4. What are the steps to repair a broken GRUB bootloader?
To repair GRUB, you need to boot from a CentOS 8 installation media, enter rescue mode, mount the root filesystem, and reinstall GRUB on the boot device.
5. How can I prevent GRUB bootloader issues in the future?
To avoid GRUB failures, regularly backup important system configurations, avoid modifying critical boot settings without proper knowledge, and ensure kernel updates are completed successfully.
Leave a Reply
You must be logged in to post a comment.