首页 文章

grubby致命错误:无法找到合适的模板

提问于
浏览
6

所以我在我的AWS EC2基础映像上升级了内核 yum -y update kernel ,我得到以下内容:

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

这是/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

所以grub.conf没有得到更新,因为我已经安装了kernel-2.6.32-504.1.3.el6.x86_64,所以上次更新内核时grub没有得到更新 . 我尝试手动添加内核:

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

然后/boot/grub/grub.conf看起来像这样:

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

但是, /vmlinuz-2.6.32-504.3.3.el6.x86_64 不是我输入的内核 . 所以我删除了它并再次尝试:

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

结果如下:

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

此时,我手动编辑/boot/grub/grub.conf到 default=0 并重启,我的EC2无法启动 . 所以我尝试了一个新的实例副本并得到了所有这些相同的错误,因此我将现有设置复制到了一个新条目:

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

并重新启动,它无法再次启动 . 还有一次尝试,我重复了上述内容,但是使用 root=/dev/xvda3 ,并且无法启动 . 所以在这一点上,我根本无法升级我的内核 . 我该怎么办?


UPDATE :我想出了/ boot / boot / stuff,我的/boot/grub/grub.conf现在看起来像这样:

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

我可以成功启动我的系统,但是其他一切仍然是正确的:安装新内核仍会导致"grubby fatal error: unable to find a suitable template",而 grubby --default-kernel 仍然导致无输出 . 我必须手动编辑我的/boot/grub/grub.conf以进行任何内核更新 .

2 回答

  • -1

    在CentOS AMI中,我看到grubby --default-kernel 在内核更新期间仍然没有输出 . 我调查了为什么使用ltrace没有输出的结果 .

    似乎grubby从ltrace的输出确认 grub.conf 的根UUID . 在我改变 grub.conf 以在我的环境中添加 root=UUID=[UUID from tune2fs] 后,我实际上可以更新内核 .

  • 0

    以下将生成正确的grub.cfg文件

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

相关问题