April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

April 2024
M T W T F S S
1234567
891011121314
15161718192021
22232425262728
2930  

grubby fatal error: unable to find a suitable template

grubby fatal error: unable to find a suitable template

Updating   : selinux-policy-3.7.19-292.el6_8.3.noarch                                                                                                             8/28
Updating   : selinux-policy-targeted-3.7.19-292.el6_8.3.noarch                                                                                                    9/28
Installing : kernel-2.6.32-642.15.1.el6.x86_64                                                                                                                   10/28
grubby fatal error: unable to find a suitable template
Updating   : ntp-4.2.6p5-10.el6.centos.2.x86_64                                                                                                                  11/28
Updating   : libtiff-3.9.4-21.el6_8.x86_64                                                                                                                       12/28
Updating   : kernel-headers-2.6.32-642.15.1.el6.x86_64                                                                                                           13/28
Updating   : tzdata-2017a-1.el6.noarch                                                                                                                           14/28
Cleanup    : kernel-2.6.32-573.26.1.el6.x86_64                                                                                                                   15/28
warning:    erase unlink of /lib/modules/2.6.32-573.26.1.el6.x86_64/weak-updates failed: No such file or directory
warning:    erase unlink of /lib/modules/2.6.32-573.26.1.el6.x86_64/modules.order failed: No such file or directory
warning:    erase unlink of /lib/modules/2.6.32-573.26.1.el6.x86_64/modules.networking failed: No such file or directory
warning:    erase unlink of /lib/modules/2.6.32-573.26.1.el6.x86_64/modules.modesetting failed: No such file or directory
warning:    erase unlink of /lib/modules/2.6.32-573.26.1.el6.x86_64/modules.drm failed: No such file or directory
warning:    erase unlink of /lib/modules/2.6.32-573.26.1.el6.x86_64/modules.block failed: No such file or directory
Cleanup    : selinux-policy-targeted-3.7.19-292.el6_8.2.noarch

mv /boot/grub/grub.conf /boot/grub/bk_grub.conf
yum -y update && yum -y reinstall kernel

add in grub.conf 


title CentOS (2.6.32-431.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-431.el6.x86_64 ro root=UUID=c5f51db1-bfef-4480-868f-dc6049906512 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /boot/initramfs-2.6.32-431.el6.x86_64.img
        
        
        
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-642.15.1.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-642.15.1.el6.x86_64 ro root=UUID=c5f51db1-bfef-4480-868f-dc6049906512 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-642.15.1.el6.x86_64.img
title CentOS (2.6.32-573.3.1.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-573.3.1.el6.x86_64 ro root=/dev/mapper/vg_db2-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_db2/lv_swap rd_NO_MD rd_LVM_LV=vg_db2/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-573.3.1.el6.x86_64.img
title CentOS (2.6.32-431.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vg_db2-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_db2/lv_swap rd_NO_MD rd_LVM_LV=vg_db2/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-431.el6.x86_64.img


or 

It is absolutely impossible to regenerate a grub.conf from scratch with any of the tools delivered by CentOS. My solution:

  1. boot your system via Install-Disk or by grub command line prompt
  2. create an empty new /boot/grub/grub.conf
  3. add the next code snippet to your grub.conf
1
2
3
4
5
6
7
8
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-279.22.1.el6.x86_64)
  root (hd0,0)
  kernel /vmlinuz-2.6.32-279.22.1.el6.x86_64 ro root=/dev/sda3
  initrd /initramfs-2.6.32-279.22.1.el6.x86_64.img

N O T E:
I have a separated /boot partition on my systems. In standard configuration delivered by CentOS /boot and / will be on the same partition. In this case, the path to kernel and initrd will start with /boot/vmlinuz... and /boot/initramfs... . The root partition mostly will be root=/dev/sda1.

Try to boot your system with your manually built grub.conf. If anything works fine you can add new boot entries by CentOS’ tool grubby. For example:

1
2
3
root@host:~ $ grubby --add-kernel="/boot/vmlinuz-2.6.32-279.22.1.el6.x86_64"\
--initrd="/boot/initramfs-2.6.32-279.22.1.el6.x86_64.img"\
--title="CentOS (2.6.32-279.22.1.el6.x86_64)" --copy-default --make-default

The tool grubby will replace the /dev/sda? device file with the UUID string of the partition.
You can use the next line to generate an entry for each kernel image in /boot/:

1
2
3
4
5
6
7
for kernel in /boot/vmlinuz-*; do \
version=`echo $kernel | awk -F'vmlinuz-' '{print $NF}'`; \
grubby --add-kernel="/boot/vmlinuz-${version}" \
--initrd="/boot/initramfs-${version}.img" \
--title="CentOS (${version})" \
--copy-default --make-default; \
done

You should check the /etc/grub.conf for duplicate entries or maybe you will resort the boot order. Reboot your system to check if anything works fine again.


Issue

    When I install a kernel from RHN, I am getting the error: grubby fatal error: unable to find a suitable template

Raw

    [root@rhel5 ~]# rpm -vhi kernel-2.6.18-274.el5.x86_64.rpm 
    Preparing...                ########################################### [100%]
       1:kernel                 ########################################### [100%]
    grubby fatal error: unable to find a suitable template 

Resolution

    Several things can cause this error: One is when /boot is not currently mounted. Remounting /boot can properly install the kernel.

Raw

        [root@rhel5 ~]# rpm -e kernel-2.6.18-274.el5

If the above command fails because of installed dependencies, use it in the following form:
Raw

        [root@rhel5 ~]# rpm -e --nodeps kernel-2.6.18-274.el5

Afterwards, ensure /boot is mounted and proceed to reinstall the kernel:
Raw

        [root@rhel5 ~]# mount /boot
        [root@rhel5 ~]# rpm -ivh kernel-2.6.18-274.el5.x86_64.rpm 
        Preparing...                ########################################### [100%]
           1:kernel                 ########################################### [100%]
        [root@rhel5 ~]# 

If you don't have the RPM available, you can always use yum:
Raw

        [root@rhel5 ~]# yum install kernel

    This error can also happen when there are multiple filesystems with same label for the root device, and the root device is specified with LABEL= in grub.conf. In that case, change the label into an unique one, or use the device name or UUID= to specify the root device in grub.conf. To change the label on /dev/sdb2 to /root-1 for example:

Raw

# e2label /dev/sdb2 /root-1

    Another cause for this error can be a bad path to the initrd in grub.conf.

    If root device in your kernel line is invalid will also cause this message. To resolve this you can edit /boot/grub/grub.conf, changing the root entry in the most recent kernel entry to point to the correct root device.

Diagnostic Steps

    To check if you have multiple filesystems with the same label run the following command (uuid's simplified for clarity):

Raw

# blkid
$ cat sos_commands/filesys/blkid 
/dev/sda1: LABEL="/boot" UUID="aaaaa" TYPE="ext3" SEC_TYPE="ext2" 
/dev/sdb1: LABEL="/boot" UUID="aaaaa" TYPE="ext3" SEC_TYPE="ext2" 
/dev/sda2: LABEL="/" UUID="bbbbb" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sdb2: LABEL="/" UUID="bbbbb" SEC_TYPE="ext2" TYPE="ext3" 

We can see above that there are 2 disks with the same label. Check to see if they have the same wwwid (these commands are for RHEL5. For RHEL6 you need to use scsi_id --whitelisted /dev/sd* instead.
Raw

# scsi_id -gus /block/sda
3600001234567
# scsi_id -gus /block/sdb
HITATCHI-abc123

The above clearly shows that they are different disks (i.e. not a multiple path to the same device).

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>