Empty /boot/grub/grub.conf of a remote server, how to recrete it from recovery?

My remote server (running CentOS 6.6 x64) can’t boot anymore.

Using the emergency recovery (a LIVE CD) i can actually look that /etc/boot/grub/grub.conf and it’s empty (0 bytes). I don’t know why, maybe a random data loss or a system update.

Is there any way to rebuild the grub.conf from he live CD? The server is configured with a RAID1 and I’m not pretty sure how to handle this.

Here are all available kernels in /boot:

-rw-r--r-- 1 root root   105200 Jul 31 13:46 config-2.6.32-431.23.3.el6.x86_64
-rw-r--r-- 1 root root   105200 Sep  9 18:02 config-2.6.32-431.29.2.el6.x86_64
-rw-r--r-- 1 root root   105195 Nov 21  2013 config-2.6.32-431.el6.x86_64
-rw-r--r-- 1 root root   106312 Nov 11 13:25 config-2.6.32-504.1.3.el6.x86_64
-rw-r--r-- 1 root root   106308 Oct 15 00:54 config-2.6.32-504.el6.x86_64
drwxr-xr-x 3 root root     4096 Aug 31 12:03 efi
drwxr-xr-x 2 root root     4096 Dec 14 18:36 grub
-rw------- 1 root root 14210073 Aug 31 12:06 initramfs-2.6.32-431.23.3.el6.x86_64.img
-rw------- 1 root root 14212715 Oct  4 20:37 initramfs-2.6.32-431.29.2.el6.x86_64.img
-rw------- 1 root root 14206180 Aug 31 12:04 initramfs-2.6.32-431.el6.x86_64.img
-rw------- 1 root root        0 Dec 14 07:22 initramfs-2.6.32-504.1.3.el6.x86_64.img
-rw------- 1 root root 16077612 Nov  1 21:49 initramfs-2.6.32-504.el6.x86_64.img
-rw-r--r-- 1 root root   193925 Jul 31 13:47 symvers-2.6.32-431.23.3.el6.x86_64.gz
-rw-r--r-- 1 root root   193945 Sep  9 18:02 symvers-2.6.32-431.29.2.el6.x86_64.gz
-rw-r--r-- 1 root root   193758 Nov 21  2013 symvers-2.6.32-431.el6.x86_64.gz
-rw-r--r-- 1 root root   200191 Nov 11 13:26 symvers-2.6.32-504.1.3.el6.x86_64.gz
-rw-r--r-- 1 root root   200191 Oct 15 00:55 symvers-2.6.32-504.el6.x86_64.gz
-rw-r--r-- 1 root root  2519815 Jul 31 13:46 System.map-2.6.32-431.23.3.el6.x86_64
-rw-r--r-- 1 root root  2519815 Sep  9 18:02 System.map-2.6.32-431.29.2.el6.x86_64
-rw-r--r-- 1 root root  2518236 Nov 21  2013 System.map-2.6.32-431.el6.x86_64
-rw-r--r-- 1 root root  2544748 Nov 11 13:25 System.map-2.6.32-504.1.3.el6.x86_64
-rw-r--r-- 1 root root  2544748 Oct 15 00:54 System.map-2.6.32-504.el6.x86_64
-rwxr-xr-x 1 root root  4133040 Jul 31 13:46 vmlinuz-2.6.32-431.23.3.el6.x86_64
-rwxr-xr-x 1 root root  4131984 Sep  9 18:02 vmlinuz-2.6.32-431.29.2.el6.x86_64
-rwxr-xr-x 1 root root  4128368 Nov 21  2013 vmlinuz-2.6.32-431.el6.x86_64
-rwxr-xr-x 1 root root  4151408 Nov 11 13:25 vmlinuz-2.6.32-504.1.3.el6.x86_64
-rwxr-xr-x 1 root root  4152336 Oct 15 00:54 vmlinuz-2.6.32-504.el6.x86_64

I tried booting with this grub.conf file (copied from another server without RAID), where UUID is actually the right one, but it’s failing:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sda1
#          initrd /boot/initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-504.1.3.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-504.1.3.el6.x86_64 ro root=UUID=8db8fd9d-c853-4b95-b34d-9b8e64996315 rd_NO_LUKS LANG=en_GB.UTF-8 rd_NO_MD  KEYTABLE=us SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rhgb quiet
        initrd /boot/initramfs-2.6.32-504.1.3.el6.x86_64.img
title CentOS 6 (2.6.32-504.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-504.el6.x86_64 ro root=UUID=8db8fd9d-c853-4b95-b34d-9b8e64996315 rd_NO_LUKS LANG=en_GB.UTF-8 rd_NO_MD  KEYTABLE=us SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rhgb quiet
        initrd /boot/initramfs-2.6.32-504.el6.x86_64.img

Answer

your boot partition contains efi folder. if you use efi booting grub donot use /etc/boot/grub/grub.conf file. so it is empty. inside efi folder you have a grub config.

also from efi partition you may use grub2 hence grub2 has grub2-mkconfig command to build configuration.

Attribution
Source : Link , Question Author : user34295 , Answer Author : Kazim SARIKAYA

Leave a Comment