Removing duplicated Boot entries and reconfiguring the correct BootCurrent entries with efibootmgr

Sometimes the BIOS of my PC does not detect some of my USB disks because they are overloaded by a lot of EFI boot entries. So,I would like to remove every redundant entry on every disk. Let's see the example below :

In this case I wanted to remove the entry "Boot0002" because I've thought that it was redundant,since there is another entry that I suspect should be able to boot FreeBSD anyway (Boot0003) :

Code:
marietto@ziomario:/usr/home/marietto/Desktop # sudo efibootmgr

Boot to FW : false
BootCurrent: 0002
Timeout    : 1 seconds
BootOrder  : 0002, 0003
+Boot0002* UEFI OS
 Boot0003* SAMSUNG HM320JI

marietto@ziomario:/usr/home/marietto/Desktop # sudo efibootmgr -B -b 02
Removing boot variable 'Boot0002'

At this point I would like to set the BootCurrent to 0003 :

Code:
marietto@ziomario:/usr/home/marietto/Desktop # sudo efibootmgr
Boot to FW : false
BootCurrent: 0002
Timeout    : 1 seconds
BootOrder  : 0003
Boot0003* SAMSUNG HM320JI

but I'm struggling between the parameters to find the correct ones.

Tried like this,but its wrong.

Code:
marietto@ziomario:/usr/home/marietto/Desktop # sudo efibootmgr -o 3,2
Boot to FW : false
BootCurrent: 0002
Timeout    : 1 seconds
BootOrder  : 0003, 0002
 Boot0003* SAMSUNG HM320JI
Boot0002: MISSING!

?
:(
 
Code:
marietto@ziomario:/usr/home/marietto/Desktop # sudo efibootmgr -v

Boot to FW : false
BootCurrent: 0002
Timeout    : 1 seconds
BootOrder  : 0003
 Boot0003* SAMSUNG HM320JI BBS(HD,,0x0)
                          PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x0,0xffff,0x0)
                          VenHw(2d6447ef-3bc9-41a0-ac19-4d51d01b4ce6,310053004c00360044004a00530030003000310035003100390035002000200020002000200020000000)


Unreferenced Variables:
 
You had at the beginning two boot entries
Code:
+Boot0002* UEFI OS
 Boot0003* SAMSUNG HM320JI

Boot0002 was removed, Boot0003 remains as the single boot entry. Now you are trying to set a boot order with a existing Boot0003 and a non-existend Boot0002 boot entry (3,2):
# sudo efibootmgr -o 3,2

After removing Boot0002 you didn't need to do anything to determine a boot order with the Boot0003 as the sole boot entry.

To get rid of BootCurrent: 0002
Code:
# sudo efibootmgr -o 3
 
You had at the beginning two boot entries
Code:
+Boot0002* UEFI OS
 Boot0003* SAMSUNG HM320JI

Boot0002 was removed, Boot0003 remains as the single boot entry. Now you are trying to set a boot order with a existing Boot0003 and a non-existend Boot0002 boot entry (3,2):


After removing Boot0002 you didn't need to do anything to determine a boot order with the Boot0003 as the sole boot entry.

To get rid of BootCurrent: 0002
Code:
# sudo efibootmgr -o 3

Code:
marietto@ziomario:/usr/home/marietto/Desktop # sudo efibootmgr -o 3
Boot to FW : false
BootCurrent: 0002
Timeout    : 1 seconds
BootOrder  : 0003
Boot0003* SAMSUNG HM320JI

marietto@ziomario:/usr/home/marietto/Desktop # sudo efibootmgr
Boot to FW : false
BootCurrent: 0002
Timeout    : 1 seconds
BootOrder  : 0003
Boot0003* SAMSUNG HM320JI

BootCurrent: 0002 is still there.
 
BootCurrent is the one you used to boot the machine. It's not going to change until you actually reboot it and boot one of the other boot entries.

Code:
     This will display the optional BootNext (if present), BootCurrent
     (currently booted method), followed by the optional Timeout value, any
     BootOrder that may be set, followed finally by all currently defined Boot
     variables, active or not.  The verbose flag, (-v), augments this output
     with the disk partition uuids, size/offset and device-path of the
     variable.  The flag will also include any unreferenced (by BootOrder)
     variables.
 
example:
Code:
$ efibootmgr
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0001,0005,0000,0003,0006,0002,0012,0013,0015,0014,0016,0017,0018,0019
Boot0000* ubuntu    HD(4,GPT,39f2b930-88fa-8f45-94c2-58beee389060,0xe0d21000,0x32000)/File(\EFI\ubuntu\shimx64.efi)
Boot0001* rEFInd Boot Manager    HD(4,GPT,39f2b930-88fa-8f45-94c2-58beee389060,0xe0d21000,0x32000)/File(\EFI\refind\refind_x64.efi)
Boot0002* FreeBSD    HD(2,GPT,b73c0a35-5728-4ed7-8784-302ed6eee5a8,0x109000,0x32000)/File(\EFI\freebsd\loader.efi)
Boot0003* slackware-15.0    HD(1,GPT,a7203afe-2054-428a-94d1-2c137842d803,0x800,0x32000)/File(\EFI\slackware-15.0\grubx64.efi)
Boot0005* slackware-15.0+    HD(1,GPT,a7203afe-2054-428a-94d1-2c137842d803,0x800,0x32000)/File(\EFI\slackware-15.0+\grubx64.efi)
Boot0006* FreeBSD    HD(1,GPT,a7203afe-2054-428a-94d1-2c137842d803,0x800,0x32000)/File(\efi\freebsd\loader.efi)
Boot0010  Setup    FvFile(721c8b66-426c-4e86-8e99-3457c46ab0b9)
Boot0011  Boot Menu    FvFile(86488440-41bb-42c7-93ac-450fbf7766bf)
Boot0012* NVMe: SPCC M.2 PCIe SSD                          PciRoot(0x0)/Pci(0x1,0x7)/Pci(0x0,0x0)/NVMe(0x1,64-79-A7-21-11-13-39-30)
Boot0013* ATA HDD: Samsung SSD 870 EVO 2TB                     PciRoot(0x0)/Pci(0x8,0x2)/Pci(0x0,0x0)/Sata(0,0,0){5962af91-4456-419f-a7b9-1f4f892ab0f6}
Boot0014* ATAPI CD:    VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,aea2090adfde214e8b3a5e471856a354)
Boot0015* USB HDD: SanDisk Cruzer Blade    PciRoot(0x0)/Pci(0x8,0x1)/Pci(0x0,0x3)/USB(1,0){aa21e833-33af-47bc-89bd-419f88c50803}
Boot0016* USB CD:    VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,86701296aa5a7848b66cd49dd3ba6a55)
Boot0017* PCI LAN:    VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,78a84aaf2b2afc4ea79cf5cc8f3d3803)
Boot0018* USB LAN:    VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,e854bca4cae7704ca322b00da0376322)
Boot0019* USB FDD:    VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,6ff015a28830b543a8b8641009461e49)
to remove entry
sudo efibootmgr -Bb 0001
to add entry
sudo efibootmgr -a -c -l /boot/efi/efi/freebsd/loader.efi -L "FreeBSD 13.2"


Change EFI boot order
copy paste that top line of numbers, 0001,0003,0002 to save time and hassle of typing everything out
make sure there are not spaces between anything, as I think FreeBSD prints out spaces 0001, 0003, 0004
then just swap out what already is with what you want to be the boot OS numbers.
sudo efibootmgr -o 0003,0001,0002
enter
done
 
Actually on my old PC I have attached the two disks below :

Code:
marietto@ziomario:/usr/home/marietto/Desktop # sudo geom disk list

Geom name: ada0
Providers:
1. Name: ada0
   Mediasize: 320072933376 (298G)
   Sectorsize: 512
   Mode: r2w2e6
   descr: SAMSUNG HM320JI
   lunid: 50f0000003101559
   ident: S16LJD0S101559
   rotationrate: unknown
   fwsectors: 63
   fwheads: 16

Geom name: da0
Providers:
1. Name: da0
   Mediasize: 2000398933504 (1.8T)
   Sectorsize: 512
   Stripesize: 4096
   Stripeoffset: 0
   Mode: r0w0e0
   descr: Seagate M3 Portable
   lunname: NM13N4CZ
   lunid: 3e4d31334e34435a
   ident: NM13N4CZ
   rotationrate: unknown
   fwsectors: 63
   fwheads: 255

I would like to have the full list of the boot entries stored on both disks,but I get only the list of those stored on the disk "SAMSUNG HM320JI". Why ? I'm sure that the disk "Seagate M3 Portable" also has a lot of boot entries stored inside. How can I list them ? I want to remove everything,because this is not a disk where I want to install an operatying system. The problem is that in the past I have installed FreeBSD on it and so,there should be some EFI boot entries. Unfortunately later I used it to store data. Neither I want to remove anything nor I want to install a new os,if this means that I should remove everything and anyway I don't want to reinstall FreeBSD only to remove some boot entries. I'm not motivated to do so.

Code:
marietto@ziomario:/usr/home/marietto/Desktop # sudo efibootmgr

Boot to FW : false
BootCurrent: 0004
Timeout    : 1 seconds
BootOrder  : 0004, 0005, 0003
+Boot0004* UEFI OS
 Boot0005* UEFI: Seagate M3 Portable 0708
 Boot0003* SAMSUNG HM320JI
 
I would like to have the full list of the boot entries stored on both disks,but I get only the list of those stored on the disk "SAMSUNG HM320JI". Why ?
EFI doesn't get its information from the disks, it gets information that's stored in EEPROM/Flash memory. You manipulate those variables using the efibootmgr(8) tool or using the boot selector in EUFI/BIOS.
 
Can you explain how can I remove the obsolete EFI boot entries stored on my disks ?
look in /boot/efi/EFI for whatever distro then delete that dir if it is there, then use

sudo efibootmgr -Bb <4 digit number of that same system if it is in the list>
 
look in /boot/efi/EFI for whatever distro then delete that dir if it is there, then use

sudo efibootmgr -Bb <4 digit number of that same system if it is in the list>

I assume that if I haven't any /boot/efi/EFI directory,there isn't any boot entry to remove,right ? So,what about those disks where previously I had installed FreeBSD or Linux and later,I have removed every file within those disks ? Are those disks free from EFI boot entries ?
 
Please help me to understand which entries between the ones below are redudant. The risk to remove some wrong entry is high and without the working entry I should reinstall the OS from the beginning. So the question of Phishfry is very pertinent.

Code:
marietto@marietto:/ # sudo efibootmgr

Boot to FW : false
BootCurrent: 0000
Timeout    : 2 seconds
BootOrder  : 0000, 0131, 0004, 00F8, 00FA, 00F7, 0008, 023E, 0002, 0240, 0241, 0242, 0003, 0001, 000
5, 000A, 0009, 0006, 0007
+Boot0000* FreeBSD-13.1-ZFS
 Boot0131* debian
 Boot0004* rEFInd Boot Manager
 Boot00F8* Windows Boot Manager
 Boot00FA* UEFI OS
 Boot00F7* UEFI OS
 Boot0008* ubuntu
 Boot023E* ubuntu
 Boot0002* FreeBSD
 Boot0240* UEFI OS
 Boot0241* UEFI OS
 Boot0242* UEFI OS
 Boot0003* blend
 Boot0001* Windows Boot Manager
 Boot0005* debian
 Boot000A* Fedora
 Boot0009* Fedora
 Boot0006* Fedora
 Boot0007* Fedora

ok,I can remove some entries easier because they are easily recognizable,but some others aren't. For examples the entries below to which OSes are tied ?

Code:
Boot00FA* UEFI OS
Boot00F7* UEFI OS
Boot0240* UEFI OS
Boot0241* UEFI OS
Boot0242* UEFI OS

It seems that FreeBSD,when installed,creates two EFI boot entries,the first one called "FreeBSD" and the second one,called "UEFI OS". Is this right ? Do you confirm this theory ?
 
The risk to remove some wrong entry is high and without the working entry I should reinstall the OS from the beginning.
No need to do a full reinstall if you mess this up. You can boot an installer image and run efibootmgr(8) from there to fix the boot entries.

If it was me I would simply remove everything and then add, one by one, only the entries I really needed.
 
again as told or explained by a few. 2 spots separate of each other, your /boot/efi/... and in efibootmgr listing that is kept in BIOS information. so all you have to do is check for an efi partition on a hard drive, or ssd, and run efibootmgr to see all of the BIOS entries then remove or swap around or whatever using efibootmgr.

you should know to remove all you got a do it delete something by whatever method provided by the app, and yes, you can have one and not the other either way.
 
I have no idea about how to add the proper EFI entries once deleted all the older ones. What is confunsing me is how can I correlate the proper EFI entry to the right disk that should boot.
 
providing you have only 1 efi partition. I'd look in that to see what is there, and you should know what OS'es you have installed on that box. you can do what SirDice suggested which was my first thought. remove everything then start over. But if you actually have rEFInd in the efi partitoin then I'd make that boot then remove everyghing that is not in that efi partiton, if I didn't know what was what, then again you have eEFInd to deal with that is on the box to get into which every one you need, I use rEFInd as well, and have my systems as backups on efibootmgr just cuz.

in FreeBSD use the -v argrment to get more information on what is located where.
as you can see I am currently using rEFInd to boot from and the rest are just there to look at.
Code:
$> sudo efibootmgr -v
Boot to FW : false
BootCurrent: 0001
Timeout    : 0 seconds
BootOrder  : 0001, 0005, 0000, 0003, 0006, 0002, 0012, 0013, 0015, 0014, 0016, 0017, 0018, 0019
+Boot0001* rEFInd Boot Manager HD(4,GPT,39f2b930-88fa-8f45-94c2-58beee389060,0xe0d21000,0x32000)/File(\EFI\refind\refind_x64.efi)
                                  ada0p4:/EFI/refind/refind_x64.efi (null)
 Boot0005* slackware-15.0+ HD(1,GPT,a7203afe-2054-428a-94d1-2c137842d803,0x800,0x32000)/File(\EFI\slackware-15.0+\grubx64.efi)
                              nvd0p1:/EFI/slackware-15.0+/grubx64.efi /boot/efi//EFI/slackware-15.0+/grubx64.efi
 Boot0000* ubuntu HD(4,GPT,39f2b930-88fa-8f45-94c2-58beee389060,0xe0d21000,0x32000)/File(\EFI\ubuntu\shimx64.efi)
                     ada0p4:/EFI/ubuntu/shimx64.efi (null)
 Boot0003* slackware-15.0 HD(1,GPT,a7203afe-2054-428a-94d1-2c137842d803,0x800,0x32000)/File(\EFI\slackware-15.0\grubx64.efi)
                             nvd0p1:/EFI/slackware-15.0/grubx64.efi /boot/efi//EFI/slackware-15.0/grubx64.efi
 Boot0006* FreeBSD HD(1,GPT,a7203afe-2054-428a-94d1-2c137842d803,0x800,0x32000)/File(\efi\freebsd\loader.efi)
                      nvd0p1:/efi/freebsd/loader.efi /boot/efi//efi/freebsd/loader.efi
 Boot0002* FreeBSD HD(2,GPT,b73c0a35-5728-4ed7-8784-302ed6eee5a8,0x109000,0x32000)/File(\EFI\freebsd\loader.efi)
 Boot0012* NVMe: SPCC M.2 PCIe SSD                       PciRoot(0x0)/Pci(0x1,0x7)/Pci(0x0,0x0)/NVMe(0x1,30-39-13-11-21-a7-79-64)
 Boot0013* ATA HDD: Samsung SSD 870 EVO 2TB                  PciRoot(0x0)/Pci(0x8,0x2)/Pci(0x0,0x0)/Sata(0x0,0x0,0x0)
 Boot0015* USB HDD: SanDisk Cruzer Blade PciRoot(0x0)/Pci(0x8,0x1)/Pci(0x0,0x3)/USB(0x1,0x0)
 Boot0014* ATAPI CD: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,aea2090adfde214e8b3a5e471856a354)
 Boot0016* USB CD: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,86701296aa5a7848b66cd49dd3ba6a55)
 Boot0017* PCI LAN: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,78a84aaf2b2afc4ea79cf5cc8f3d3803)
 Boot0018* USB LAN: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,e854bca4cae7704ca322b00da0376322)
 Boot0019* USB FDD: VenMsg(bc7838d2-0f82-4d60-8316-c068ee79d25b,6ff015a28830b543a8b8641009461e49)


Unreferenced Variables:
 Boot0011  Boot Menu FvFile(86488440-41bb-42c7-93ac-450fbf7766bf)
 Boot0010  Setup FvFile(721c8b66-426c-4e86-8e99-3457c46ab0b9)
 
Back
Top