如何在linux 7中验证当前内核版本的当前索引是什么
例如
我想知道内核 - 3.10.0-327.18.2.el7.x86_64 是否位于index=0或index=1或index=2等
是否可以验证索引号是多少?在 Linux 7 上
uname -r
3.10.0-327.18.2.el7.x86_64
grubby --info=ALL
index=0
kernel=/boot/vmlinuz-3.10.0-327.18.2.el7.x86_64
args="ro rd.lvm.lv=rootvg/swap rd.lvm.lv=rootvg/slash vconsole.font=latarcyrheb-sun16 crashkernel=auto vconsole.keymap=us vga=0x314 net.ifnames=0 ipv6.disable=1 rd.shell LANG=en_US.UTF-8"
root=/dev/mapper/rootvg-slash
initrd=/boot/initramfs-3.10.0-327.18.2.el7.x86_64.img
title=Red Hat Enterprise Linux Server (3.10.0-327.18.2.el7.x86_64) 7.2 (Maipo)
index=1
kernel=/boot/vmlinuz-3.10.0-327.10.1.el7.x86_64
args="ro rd.lvm.lv=rootvg/swap rd.lvm.lv=rootvg/slash vconsole.font=latarcyrheb-sun16 crashkernel=auto vconsole.keymap=us vga=0x314 net.ifnames=0 ipv6.disable=1 rd.shell LANG=en_US.UTF-8"
root=/dev/mapper/rootvg-slash
initrd=/boot/initramfs-3.10.0-327.10.1.el7.x86_64.img
title=Red Hat Enterprise Linux Server (3.10.0-327.10.1.el7.x86_64) 7.2 (Maipo)
index=2
kernel=/boot/vmlinuz-3.10.0-327.4.5.el7.x86_64
args="ro rd.lvm.lv=rootvg/swap rd.lvm.lv=rootvg/slash vconsole.font=latarcyrheb-sun16 crashkernel=auto vconsole.keymap=us vga=0x314 net.ifnames=0 ipv6.disable=1 rd.shell LANG=en_US.UTF-8"
root=/dev/mapper/rootvg-slash
initrd=/boot/initramfs-3.10.0-327.4.5.el7.x86_64.img
title=Red Hat Enterprise Linux Server (3.10.0-327.4.5.el7.x86_64) 7.2 (Maipo)
index=3
kernel=/boot/vmlinuz-0-rescue-b2c5e6a1c5ea4cb5be82100bd7dc3469
args="ro rd.lvm.lv=rootvg/swap rd.lvm.lv=rootvg/slash vconsole.font=latarcyrheb-sun16 crashkernel=auto vconsole.keymap=us vga=0x314 net.ifnames=0 ipv6.disable=1 rd.shell"
root=/dev/mapper/rootvg-slash
initrd=/boot/initramfs-0-rescue-b2c5e6a1c5ea4cb5be82100bd7dc3469.img
title=Red Hat Enterprise Linux Server, with Linux 0-rescue- b2c5e6a1c5ea4cb5be82100bd7dc3469
index=4
non linux entry
答案1
$ sudo grubby --info=ALL | grep -B1 '^kernel=' | grep -B1 `cat /proc/cmdline | awk -v RS=" " '/^BOOT_IMAGE=/ {print substr($0,12)}'`$ | head -n1
index=0
$
参考: