grubby fatal error: unable to find a suitable template

DrStrangepork picture DrStrangepork · Dec 30, 2014 · Viewed 8k times · Source

So I upgraded kernel yum -y update kernel on my AWS EC2 base image, and I get the following:

Running Transaction
  Installing : kernel-2.6.32-504.3.3.el6.x86_64
grubby fatal error: unable to find a suitable template

Here is the contents of /boot/grub/grub.conf:

default=0
timeout=0
hiddenmenu
title CentOS (2.6.32-358.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-358.el6.x86_64 ro root=LABEL=rootfs console=ttyS0
        initrd /boot/initramfs-2.6.32-358.el6.x86_64.img

So grub.conf is not getting updated, and since I already have kernel-2.6.32-504.1.3.el6.x86_64 installed, grub did not get updated the last time I updated kernel either. I tried adding the kernel manually:

grubby --grub --add-kernel="/boot/vmlinuz-2.6.32-504.3.3.el6.x86_64 ro root=LABEL=rootfs \
  console=ttyS0" --title="CentOS (2.6.32-504.3.3.el6.x86_64)" \
  --initrd=/boot/initramfs-2.6.32-504.3.3.el6.x86_64.img

and then /boot/grub/grub.conf looked like this:

default=0
timeout=0
hiddenmenu
title CentOS (2.6.32-504.3.3.el6.x86_64)
        kernel /vmlinuz-2.6.32-504.3.3.el6.x86_64 ro root=LABEL=rootfs console=ttyS0
        initrd /initramfs-2.6.32-504.3.3.el6.x86_64.img
title CentOS (2.6.32-358.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-358.el6.x86_64 ro root=LABEL=rootfs console=ttyS0
        initrd /boot/initramfs-2.6.32-358.el6.x86_64.img

However, /vmlinuz-2.6.32-504.3.3.el6.x86_64 is not the kernel I entered. So I removed that and tried again with:

grubby --grub --add-kernel="/boot/boot/vmlinuz-2.6.32-504.3.3.el6.x86_64 ro root=LABEL=rootfs \
  console=ttyS0" --title="CentOS (2.6.32-504.3.3.el6.x86_64)" \
  --initrd=/boot/boot/initramfs-2.6.32-504.3.3.el6.x86_64.img

which resulted in this:

timeout=0
default=1
hiddenmenu
title CentOS (2.6.32-504.3.3.el6.x86_64)
        kernel /boot/vmlinuz-2.6.32-504.3.3.el6.x86_64 ro root=LABEL=rootfs console=ttyS0 root=(hd0,0)
        initrd /boot/initramfs-2.6.32-504.3.3.el6.x86_64.img
title CentOS (2.6.32-358.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-358.el6.x86_64 ro root=LABEL=rootfs console=ttyS0
        initrd /boot/initramfs-2.6.32-358.el6.x86_64.img

At this point, I manually edited /boot/grub/grub.conf to default=0 and rebooted, and my EC2 wouldn't boot. So I tried a new instance copy and got all these same errors, so I copied the existing settings to a new entry:

default=0
timeout=0
hiddenmenu
title CentOS (2.6.32-504.3.3.el6.x86_64)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.32-504.3.3.el6.x86_64 ro root=LABEL=rootfs console=ttyS0
        initrd /boot/initramfs-2.6.32-504.3.3.el6.x86_64.img

And rebooted, and it fails to boot again. Yet another try, I repeated the above but with root=/dev/xvda3, and that failed to boot as well. So at this point, I have no way at all of upgrading my kernel. What do I do?


UPDATE: I figured out the /boot/boot/ stuff, and my /boot/grub/grub.conf now looks like this:

default=0
timeout=0
hiddenmenu
title CentOS (2.6.32-504.3.3.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-504.3.3.el6.x86_64 ro root=LABEL=rootfs console=ttyS0
        initrd /initramfs-2.6.32-504.3.3.el6.x86_64.img

And I can successfully boot my system, however everything else about this remains true: installing a new kernel still results in "grubby fatal error: unable to find a suitable template", and grubby --default-kernel still results in no output. I have to edit my /boot/grub/grub.conf manually for any kernel update.

Answer

kentaost picture kentaost · Mar 26, 2015

I saw grubby --default-kernel still results in no output during kernel update too in CentOS AMI. I investigated why results in no output using ltrace.

It seems that grubby confirms root UUID of grub.conf from outputs of ltrace. I could actually update the kernel after I changed grub.conf to add root=UUID=[UUID from tune2fs] in my environment.