DrS*_*ork 6 linux boot kernel grub
所以我yum -y update kernel在AWS EC2基础映像上升级了内核,得到以下内容:
Running Transaction
Installing : kernel-2.6.32-504.3.3.el6.x86_64
grubby fatal error: unable to find a suitable template
Run Code Online (Sandbox Code Playgroud)
这是/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
Run Code Online (Sandbox Code Playgroud)
所以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
Run Code Online (Sandbox Code Playgroud)
然后/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
Run Code Online (Sandbox Code Playgroud)
但是,/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
Run Code Online (Sandbox Code Playgroud)
结果如下:
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
Run Code Online (Sandbox Code Playgroud)
此时,我手动编辑了/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
Run Code Online (Sandbox Code Playgroud)
并重新启动,它无法再次启动.又一次尝试,我重复了上述但是root=/dev/xvda3,并且也没能启动.所以在这一点上,我根本无法升级我的内核.我该怎么办?
更新:我想出了/ 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
Run Code Online (Sandbox Code Playgroud)
我可以成功启动我的系统,但是其他一切仍然是正确的:安装新内核仍会导致"肮脏的致命错误:无法找到合适的模板",grubby --default-kernel仍然导致无输出.我必须手动编辑我的/boot/grub/grub.conf以进行任何内核更新.