grub.cfg deleted

Issues related to applications and software problems
Post Reply
knzzz
Posts: 136
Joined: 2017/02/25 12:41:42

grub.cfg deleted

Post by knzzz » 2018/03/12 03:59:47

Hi Team,

can some one please share the steps of how to create the grub.cfg file , in case if it got deleted from grub2 folder need assistance to fix it and also how to boot the system back to normal

Regards
Kanna

User avatar
TrevorH
Forum Moderator
Posts: 27127
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: grub.cfg deleted

Post by TrevorH » 2018/03/12 07:13:55

man grub2-mkconfig
CentOS 6 will die in November 2020 - migrate sooner rather than later!
CentOS 5 has been EOL for nearly 3 years and should no longer be used for anything!
Full time Geek, part time moderator. Use the FAQ Luke

desertcat
Posts: 662
Joined: 2014/08/07 02:17:29
Location: Tucson, AZ

Re: grub.cfg deleted

Post by desertcat » 2018/03/14 12:23:54

knzzz wrote:Hi Team,

can some one please share the steps of how to create the grub.cfg file , in case if it got deleted from grub2 folder need assistance to fix it and also how to boot the system back to normal

Regards
Kanna
I HATE grub2!!! There is a useful utility that everyone should have called Grub Customizer, and will help you recover from disasters.

There are 3 Directories that are important to recover from a whacked system you should check: 1) /boot/grub2 (under which you find grub.cfg); 2) /etc/default (under which you find grub); and 3) /etc/grub.d (which contains the files (?) used by grub.cfg). Open any text editor and look at /etc/grub.d, and you *should* see something like this:

*00_header
*00_tuned
*01_users
*10_linux
*20_linux_xen
*20_ppc_terminfo
*30_os-prober
*40_custom
*41_custom


That is the order in which they should appear. If they don't you are severely whacked. What I've done is sometimes is to simply rename the various out of whack files back to the above list ie if I have a file called *20_os-prober, and I know that it should be *30_os-prober I simply rename it back to its original file name. Once I am satisfied I have the list back in order I run:

grub2-mkconfig -o /boot/grub2/grub.cfg

With luck it will now boot your machine. Having learned my lesson the hard way I have made copies of /boot/grub2/grub.cfg; /etc/default/grub; and /etc/grub.d and its lists of files. In the event somehow this my system gets mangled, I simply go over to the back up files, wipe out the mangled files, and copy my backup into place then run

grub2-mkconfig -o /boot/grub2/grub.cfg

and reboot the system. Many of the so-called "grub-recovery" tools are based on this same idea -- make copies of all three of these directories followed by the "grub2-mkconfig -o /boot/grub2/grub.cfg" command.

If you want to download Grub Customizer the package for CentOS 7 is grub-customizer-5.0.6-1.el7.x86_64.rpm.

Hope this helps

Post Reply

Return to “CentOS 7 - Software Support”