Linux基础——Gubby调整Bclinux8的内核启动顺序和关联grubenv丢失问题

Gubby调整Bclinux8的内核启动顺序

和关联grubenv丢失问题

一、grubby帮助文档

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(base) [root@NewOSBC8 ~]# grubby --help
Usage: grubby [OPTION...]
      --add-kernel=kernel-path            add an entry for the specified kernel
      --args=args                         default arguments for the new kernel or new arguments for kernel being updated)
      --bad-image-okay                    don't sanity check images in boot entries (for testing only)
  -c, --config-file=path                  path to grub config file to update ("-" for stdin)
      --copy-default                      use the default boot entry as a template for the new entry being added; if the default is not a linux image, or if the kernel referenced by the default image does not exist, the
                                          first linux entry whose kernel does exist is used as the template
      --default-kernel                    display the path of the default kernel
      --default-index                     display the index of the default kernel
      --default-title                     display the title of the default kernel
      --env=path                          path for environment data
      --grub2                             configure grub2 bootloader
      --info=kernel-path                  display boot information for specified kernel
      --initrd=initrd-path                initrd image for the new kernel
  -i, --extra-initrd=initrd-path          auxiliary initrd image for things other than the new kernel
      --make-default                      make the newly added entry the default boot entry
      --remove-args=STRING                remove kernel arguments
      --remove-kernel=kernel-path         remove all entries for the specified kernel
      --set-default=kernel-path           make the first entry referencing the specified kernel the default
      --set-default-index=entry-index     make the given entry index the default entry
      --title=entry-title                 title to use for the new kernel entry
      --update-kernel=kernel-path         updated information for the specified kernel
      --zipl                              configure zipl bootloader
  -b, --bls-directory                     path to directory containing the BootLoaderSpec fragment files
 
Help options:
  -?, --help                              Show this help message

二、grubby修改内核启动顺序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
1、查看当前所有内核详情
 
(base) [root@NewOSBC8 ~]# grubby --info=ALL
index=0
kernel="/boot/vmlinuz-4.19.0-240.23.35.el8_2.bclinux.x86_64+debug"
args="ro crashkernel=160M resume=/dev/mapper/bel_newosbc8-swap rd.lvm.lv=bel_newosbc8/root rd.lvm.lv=bel_newosbc8/swap rhgb quiet $tuned_params"
root="/dev/mapper/bel_newosbc8-root"
initrd="/boot/initramfs-4.19.0-240.23.35.el8_2.bclinux.x86_64+debug.img $tuned_initrd"
title="BigCloud Enterprise Linux (4.19.0-240.23.35.el8_2.bclinux.x86_64+debug) 8.2 (Core)"
id="ced6230f6fe049c493cd1845587c3c75-4.19.0-240.23.35.el8_2.bclinux.x86_64+debug"
index=1
kernel="/boot/vmlinuz-4.19.0-240.23.35.el8_2.bclinux.x86_64"
args="ro crashkernel=160M resume=/dev/mapper/bel_newosbc8-swap rd.lvm.lv=bel_newosbc8/root rd.lvm.lv=bel_newosbc8/swap rhgb quiet $tuned_params"
root="/dev/mapper/bel_newosbc8-root"
initrd="/boot/initramfs-4.19.0-240.23.35.el8_2.bclinux.x86_64.img $tuned_initrd"
title="BigCloud Enterprise Linux (4.19.0-240.23.35.el8_2.bclinux.x86_64) 8.2 (Core)"
id="ced6230f6fe049c493cd1845587c3c75-4.19.0-240.23.35.el8_2.bclinux.x86_64"
index=2
kernel="/boot/vmlinuz-4.19.0-240.23.11.el8_2.bclinux.x86_64"
args="ro crashkernel=160M resume=/dev/mapper/bel_newosbc8-swap rd.lvm.lv=bel_newosbc8/root rd.lvm.lv=bel_newosbc8/swap rhgb quiet $tuned_params"
root="/dev/mapper/bel_newosbc8-root"
initrd="/boot/initramfs-4.19.0-240.23.11.el8_2.bclinux.x86_64.img $tuned_initrd"
title="BigCloud Enterprise Linux (4.19.0-240.23.11.el8_2.bclinux.x86_64) 8.2 (Core)"
id="ced6230f6fe049c493cd1845587c3c75-4.19.0-240.23.11.el8_2.bclinux.x86_64"
index=3
kernel="/boot/vmlinuz-0-rescue-ced6230f6fe049c493cd1845587c3c75"
args="ro crashkernel=160M resume=/dev/mapper/bel_newosbc8-swap rd.lvm.lv=bel_newosbc8/root rd.lvm.lv=bel_newosbc8/swap rhgb quiet"
root="/dev/mapper/bel_newosbc8-root"
initrd="/boot/initramfs-0-rescue-ced6230f6fe049c493cd1845587c3c75.img"
title="BigCloud Enterprise Linux (0-rescue-ced6230f6fe049c493cd1845587c3c75) 8.2 (Core)"
id="ced6230f6fe049c493cd1845587c3c75-0-rescue"
 
2、设置内核启动顺序index值
(base) [root@NewOSBC8 ~]# grubby --set-default-index=1
The default is /boot/loader/entries/ced6230f6fe049c493cd1845587c3c75-4.19.0-240.23.35.el8_2.bclinux.x86_64.conf with index 1 and kernel /boot/vmlinuz-4.19.0-240.23.35.el8_2.bclinux.x86_64
 
3、查看默认启动内核信息
(base) [root@NewOSBC8 ~]# grubby --default-kernel
/boot/vmlinuz-4.19.0-240.23.35.el8_2.bclinux.x86_64s

  

三、/boot/grub2/grubenv文件情况或损坏

1、步骤一:通过修复模式进入系统;

2、步骤二:根据如下方法修复grubenv文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Legacy模式:
 
(1)创建一个空的grubenv文件。
 
# grub2-editenv /boot/grub2/grubenv create
 
(2)重新生成grub.cfg文件,在生成grub.cfg的同时会自动写入grubenv文件。
 
# grub2-mkconfig -o /boot/grub2/grub.cfg
 
UEFI模式:
 
(1)创建一个空的grubenv。
 
# grub2-editenv /boot/efi/EFI/实际系统路径/grubenv create
 
(2)创建 /boot/grub2/grubenv/boot/efi/EFI/实际系统路径/grubenv的软链接。
 
# ln -sf /boot/efi/EFI/实际系统路径/grubenv /boot/grub2/grubenv
 
(3)重新生成grub.cfg文件,在生成grub.cfg的同时会自动写入grubenv文件。
 
# grub2-mkconfig -o /boot/efi/EFI/实际系统路径/grub.cfg

 注:如果是uefi,例如:/boot/grub2/grubenv和/boot/efi/EFI/bclinux/grubenv一个目录丢失,导致无法启动主机;

3、步骤三:检查grubenv文件是否生成saved_entry=<paramater>参数。

4、重启系统

1
reboot

  

 

posted on   gkhost  阅读(92)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示