UEFI启动模式安装的服务器出现多个启动项的清理方法

本文介绍了如何在服务器上手动或通过脚本清理UEFI启动模式下多余的openEuler启动项。手动清理时,通过efibootmgr命令查看并删除无效UUID。脚本清理则利用shell脚本匹配并删除不含当前使用UUID的启动项,以优化启动菜单。
摘要由CSDN通过智能技术生成

UEFI启动模式安装的服务器,每安装一次,就会出现1个启动项,多次安装以后就会出现多个启动项,实际上只有最后一个有用,本文讲解如何清除无效的启动项。

  1. 手动清理

  1. 执行以下命令查看当前启动EFI硬盘的UUID

[root@openeuler ~]# blkid |grep EFI
/dev/sda1: UUID="0AFD-AB3E" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="596ff23c-ded3-4b84-8660-2169990f5c3b"

本例中的UUID即为596ff23c-ded3-4b84-8660-2169990f5c3b

  1. 查看系统引导菜单

[root@openeuler ~]# efibootmgr
BootCurrent: 000A
BootOrder: 000A,0009,0008,0007,0006,0005,0003,0000,0001,0002,0004
Boot0000* EFI Virtual disk (0.0)        PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)/SCSI(0,0)
Boot0001* EFI VMware Virtual IDE CDROM Drive (IDE 0:0)  PciRoot(0x0)/Pci(0x7,0x1)/Ata(0,0,0)
Boot0002* EFI Network   PciRoot(0x0)/Pci(0x16,0x0)/Pci(0x0,0x0)/MAC(005056ad3eb7,1)
Boot0003* openEuler     HD(3,GPT,c386ab88-89b0-4b05-8193-fb42c652be36,0x1ed3800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0004* EFI Internal Shell (Unsupported option)       MemoryMapped(11,0xefcb018,0xf3f7017)/FvFile(c57ad6b7-0515-40a8-9d21-551652854e37)
Boot0005* openEuler     HD(1,GPT,88d93c99-f885-4b6f-888c-c4326e220995,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0006* openeuler     HD(1,GPT,82b909b2-5646-458d-b69f-c0df1f01ec54,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0007* openEuler     HD(1,GPT,21ba65ee-4f4d-4f93-8230-6ebe6302bb27,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0008* openEuler     HD(1,GPT,f5b837aa-b840-4391-90d3-476139de09fc,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0009* openEuler     HD(1,GPT,a0b4ba34-0b56-4952-ade5-bf208902a0b6,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot000A* openEuler     HD(1,GPT,596ff23c-ded3-4b84-8660-2169990f5c3b,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)

本例中有多个openEuler的系统启动选单,过滤显示更直观

通过UUID即可确定当前有效的是哪一个,通常是最后一个在用。返回信息的第一列为启动项id,以Boot和*字符中的为准。

  1. 通过“efibootmgr -b ${unusedUUID} -B”手动逐个删除即可。

二、脚本清理

如果启动项太多,且有固定标识字符串,则可通过shell脚本清理

以上例主机为例,重复的启动项均包含“openEuler”字串,可通过以下脚本,一次运行即可清理全部的无效启动项(同时备份当前启动项为脚本目录下的efibootmgr.running文件):

#!/bin/bash
##__author__='daigjianbing'

checkinfo="openEuler"
usedUUID=`blkid |grep EFI|awk -F '"' '{print $10 }'`
echo $usedUUID
efibootmgr |grep ${checkinfo}|grep $usedUUID |tee efibootmgr.running
unusedUUID=`efibootmgr |grep openEuler|grep -v $usedUUID|awk '{print $1}'`
for i in $unusedUUID
do
    id=`echo ${i:4:4}`
    echo "###########################"
    echo "cleaning boot menu $id:"
    echo "efibootmgr -b $id -B"
    efibootmgr -b $id -B
    echo "###########################"
done 

执行结果

[root@openeuler tmp]# sh clearUEFImenu.sh 
596ff23c-ded3-4b84-8660-2169990f5c3b
Boot000A* openEuler     HD(1,GPT,596ff23c-ded3-4b84-8660-2169990f5c3b,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
###########################
cleaning boot menu 0003:
efibootmgr -b 0003 -B
BootCurrent: 000A
BootOrder: 000A,0009,0008,0007,0006,0005,0000,0001,0002,0004
Boot0000* EFI Virtual disk (0.0)        PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)/SCSI(0,0)
Boot0001* EFI VMware Virtual IDE CDROM Drive (IDE 0:0)  PciRoot(0x0)/Pci(0x7,0x1)/Ata(0,0,0)
Boot0002* EFI Network   PciRoot(0x0)/Pci(0x16,0x0)/Pci(0x0,0x0)/MAC(005056ad3eb7,1)
Boot0004* EFI Internal Shell (Unsupported option)       MemoryMapped(11,0xefcb018,0xf3f7017)/FvFile(c57ad6b7-0515-40a8-9d21-551652854e37)
Boot0005* openEuler     HD(1,GPT,88d93c99-f885-4b6f-888c-c4326e220995,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0006* openeuler     HD(1,GPT,82b909b2-5646-458d-b69f-c0df1f01ec54,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0007* openEuler     HD(1,GPT,21ba65ee-4f4d-4f93-8230-6ebe6302bb27,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0008* openEuler     HD(1,GPT,f5b837aa-b840-4391-90d3-476139de09fc,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0009* openEuler     HD(1,GPT,a0b4ba34-0b56-4952-ade5-bf208902a0b6,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot000A* openEuler     HD(1,GPT,596ff23c-ded3-4b84-8660-2169990f5c3b,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
###########################
###########################
cleaning boot menu 0005:
efibootmgr -b 0005 -B
BootCurrent: 000A
BootOrder: 000A,0009,0008,0007,0006,0000,0001,0002,0004
Boot0000* EFI Virtual disk (0.0)        PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)/SCSI(0,0)
Boot0001* EFI VMware Virtual IDE CDROM Drive (IDE 0:0)  PciRoot(0x0)/Pci(0x7,0x1)/Ata(0,0,0)
Boot0002* EFI Network   PciRoot(0x0)/Pci(0x16,0x0)/Pci(0x0,0x0)/MAC(005056ad3eb7,1)
Boot0004* EFI Internal Shell (Unsupported option)       MemoryMapped(11,0xefcb018,0xf3f7017)/FvFile(c57ad6b7-0515-40a8-9d21-551652854e37)
Boot0006* openeuler     HD(1,GPT,82b909b2-5646-458d-b69f-c0df1f01ec54,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0007* openEuler     HD(1,GPT,21ba65ee-4f4d-4f93-8230-6ebe6302bb27,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0008* openEuler     HD(1,GPT,f5b837aa-b840-4391-90d3-476139de09fc,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0009* openEuler     HD(1,GPT,a0b4ba34-0b56-4952-ade5-bf208902a0b6,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot000A* openEuler     HD(1,GPT,596ff23c-ded3-4b84-8660-2169990f5c3b,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
###########################
###########################
cleaning boot menu 0006:
efibootmgr -b 0006 -B
BootCurrent: 000A
BootOrder: 000A,0009,0008,0007,0000,0001,0002,0004
Boot0000* EFI Virtual disk (0.0)        PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)/SCSI(0,0)
Boot0001* EFI VMware Virtual IDE CDROM Drive (IDE 0:0)  PciRoot(0x0)/Pci(0x7,0x1)/Ata(0,0,0)
Boot0002* EFI Network   PciRoot(0x0)/Pci(0x16,0x0)/Pci(0x0,0x0)/MAC(005056ad3eb7,1)
Boot0004* EFI Internal Shell (Unsupported option)       MemoryMapped(11,0xefcb018,0xf3f7017)/FvFile(c57ad6b7-0515-40a8-9d21-551652854e37)
Boot0007* openEuler     HD(1,GPT,21ba65ee-4f4d-4f93-8230-6ebe6302bb27,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0008* openEuler     HD(1,GPT,f5b837aa-b840-4391-90d3-476139de09fc,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0009* openEuler     HD(1,GPT,a0b4ba34-0b56-4952-ade5-bf208902a0b6,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot000A* openEuler     HD(1,GPT,596ff23c-ded3-4b84-8660-2169990f5c3b,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
###########################
###########################
cleaning boot menu 0007:
efibootmgr -b 0007 -B
BootCurrent: 000A
BootOrder: 000A,0009,0008,0000,0001,0002,0004
Boot0000* EFI Virtual disk (0.0)        PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)/SCSI(0,0)
Boot0001* EFI VMware Virtual IDE CDROM Drive (IDE 0:0)  PciRoot(0x0)/Pci(0x7,0x1)/Ata(0,0,0)
Boot0002* EFI Network   PciRoot(0x0)/Pci(0x16,0x0)/Pci(0x0,0x0)/MAC(005056ad3eb7,1)
Boot0004* EFI Internal Shell (Unsupported option)       MemoryMapped(11,0xefcb018,0xf3f7017)/FvFile(c57ad6b7-0515-40a8-9d21-551652854e37)
Boot0008* openEuler     HD(1,GPT,f5b837aa-b840-4391-90d3-476139de09fc,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot0009* openEuler     HD(1,GPT,a0b4ba34-0b56-4952-ade5-bf208902a0b6,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot000A* openEuler     HD(1,GPT,596ff23c-ded3-4b84-8660-2169990f5c3b,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
###########################
###########################
cleaning boot menu 0008:
efibootmgr -b 0008 -B
BootCurrent: 000A
BootOrder: 000A,0009,0000,0001,0002,0004
Boot0000* EFI Virtual disk (0.0)        PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)/SCSI(0,0)
Boot0001* EFI VMware Virtual IDE CDROM Drive (IDE 0:0)  PciRoot(0x0)/Pci(0x7,0x1)/Ata(0,0,0)
Boot0002* EFI Network   PciRoot(0x0)/Pci(0x16,0x0)/Pci(0x0,0x0)/MAC(005056ad3eb7,1)
Boot0004* EFI Internal Shell (Unsupported option)       MemoryMapped(11,0xefcb018,0xf3f7017)/FvFile(c57ad6b7-0515-40a8-9d21-551652854e37)
Boot0009* openEuler     HD(1,GPT,a0b4ba34-0b56-4952-ade5-bf208902a0b6,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
Boot000A* openEuler     HD(1,GPT,596ff23c-ded3-4b84-8660-2169990f5c3b,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
###########################
###########################
cleaning boot menu 0009:
efibootmgr -b 0009 -B
BootCurrent: 000A
BootOrder: 000A,0000,0001,0002,0004
Boot0000* EFI Virtual disk (0.0)        PciRoot(0x0)/Pci(0x15,0x0)/Pci(0x0,0x0)/SCSI(0,0)
Boot0001* EFI VMware Virtual IDE CDROM Drive (IDE 0:0)  PciRoot(0x0)/Pci(0x7,0x1)/Ata(0,0,0)
Boot0002* EFI Network   PciRoot(0x0)/Pci(0x16,0x0)/Pci(0x0,0x0)/MAC(005056ad3eb7,1)
Boot0004* EFI Internal Shell (Unsupported option)       MemoryMapped(11,0xefcb018,0xf3f7017)/FvFile(c57ad6b7-0515-40a8-9d21-551652854e37)
Boot000A* openEuler     HD(1,GPT,596ff23c-ded3-4b84-8660-2169990f5c3b,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)
###########################

再次验证,硬盘启动项只有正确的一项了:

[root@openeuler tmp]# efibootmgr |grep openEuler
Boot000A* openEuler     HD(1,GPT,596ff23c-ded3-4b84-8660-2169990f5c3b,0x800,0x12c000)/File(\EFI\openEuler\shimx64.efi)

至此,启动项修复完成。

要在BIOS中删除UEFI启动项,您可以按照以下步骤进行操作: 1. 首先,进入计算机的BIOS设置。通常,在开机时按下指定的按键(如F2、Delete或F12)可以进入BIOS设置界面。您可以在计算机开机时的启动画面上找到相应的提示信息。 2. 在BIOS设置界面中,找到启动选项。它可能位于不同的标签页或菜单中,具体位置取决于您计算机的型号和BIOS版本。 3. 在启动选项中,您应该能够看到现有的UEFI启动项列表。请注意,不同的BIOS界面可能会以不同的方式显示这些项。 4. 使用键盘上的方向键或鼠标(如果BIOS支持鼠标),选择要删除UEFI启动项。 5. 选择删除选项。在某些BIOS中,您可能需要按下特定的键(如F9或F10)来删除选定的启动项。 6. 确认删除操作。请注意,删除启动项可能会导致无法引导到相应的操作系统或引导文件。因此,请仔细确认您要删除启动项是否正确。 7. 完成删除后,保存并退出BIOS设置。通常,您可以使用相应的按键(如F10)保存更改并重新启动计算机。 请注意,上述步骤的具体操作可能因计算机的品牌、型号和BIOS版本而有所不同。建议您在进行任何BIOS设置更改之前,先阅读计算机的用户手册或参考制造商的支持文档以获取准确的操作说明。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [UEFI启动模式安装服务器出现多个启动项清理方法](https://blog.csdn.net/forestqq/article/details/129185809)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [轻松管理您的 EFIUEFI 启动项 EasyUEFI Enterprise 4.0 + x64.zip](https://download.csdn.net/download/dbnjzy/19333743)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

代先生.重庆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值