s-n-ushakov / rename-efi-entry

A Bash script to rename EFI boot entries
BSD 2-Clause "Simplified" License
87 stars 15 forks source link

script doesn't rename entry -- no EFI data found for any label matching '...' #9

Open emk2203 opened 6 months ago

emk2203 commented 6 months ago

I am trying to rename an EFI entry from 'endeavouros' to 'EndeavourOS', but I only get an error message:

/home/emk2203/bin/rename-efi-entry.bash : ERROR : no EFI data found for any label matching 'endeavouros'.

The command I used was: sudo ~/bin/rename-efi-entry.bash endeavouros EndeavourOS 0002. Running without the 0002 at the end gives the same result.

This is the output of rename-efi-entry without sudo (efibootmgr --verbose doesn't show all entries):

Current EFI data:
BootCurrent: 0002
Timeout: 0 seconds
BootOrder: 0000,0002,0001,0015,0006,0007,000E,0008,0012,0016,0017
Boot0000* Ubuntu        HD(1,GPT,d86849d8-3872-4d72-96f7-8fd1a9643728,0x800,0x100000)/\EFI\ubuntu\shimx64.efi
      dp: 04 01 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 00 10 00 00 00 00 00 d8 49 68 d8 72 38 72 4d 96 f7 8f d1 a9 64 37 28 02 02 / 04 04 34 00 5c 00 45 00 46 00 49 00 5c 00 75 00 62 00 75 00 6e 00 74 00 75 00 5c 00 73 00 68 00 69 00 6d 00 78 00 36 00 34 00 2e 00 65 00 66 00 69 00 00 00 / 7f ff 04 00
Boot0001* Windows Boot Manager  HD(1,GPT,d86849d8-3872-4d72-96f7-8fd1a9643728,0x800,0x100000)/\EFI\Microsoft\Boot\bootmgfw.efi57494e444f5753000100000088000000780000004200430044004f0042004a004500430054003d007b00390064006500610038003600320063002d0035006300640064002d0034006500370030002d0061006300630031002d006600330032006200330034003400640034003700390035007d00000001000100000010000000040000007fff0400
      dp: 04 01 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 00 10 00 00 00 00 00 d8 49 68 d8 72 38 72 4d 96 f7 8f d1 a9 64 37 28 02 02 / 04 04 46 00 5c 00 45 00 46 00 49 00 5c 00 4d 00 69 00 63 00 72 00 6f 00 73 00 6f 00 66 00 74 00 5c 00 42 00 6f 00 6f 00 74 00 5c 00 62 00 6f 00 6f 00 74 00 6d 00 67 00 66 00 77 00 2e 00 65 00 66 00 69 00 00 00 / 7f ff 04 00
    data: 57 49 4e 44 4f 57 53 00 01 00 00 00 88 00 00 00 78 00 00 00 42 00 43 00 44 00 4f 00 42 00 4a 00 45 00 43 00 54 00 3d 00 7b 00 39 00 64 00 65 00 61 00 38 00 36 00 32 00 63 00 2d 00 35 00 63 00 64 00 64 00 2d 00 34 00 65 00 37 00 30 00 2d 00 61 00 63 00 63 00 31 00 2d 00 66 00 33 00 32 00 62 00 33 00 34 00 34 00 64 00 34 00 37 00 39 00 35 00 7d 00 00 00 01 00 01 00 00 00 10 00 00 00 04 00 00 00 7f ff 04 00
Boot0002* endeavouros   HD(1,GPT,d86849d8-3872-4d72-96f7-8fd1a9643728,0x800,0x100000)/\EFI\endeavouros\grubx64.efi
      dp: 04 01 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 00 10 00 00 00 00 00 d8 49 68 d8 72 38 72 4d 96 f7 8f d1 a9 64 37 28 02 02 / 04 04 3e 00 5c 00 45 00 46 00 49 00 5c 00 65 00 6e 00 64 00 65 00 61 00 76 00 6f 00 75 00 72 00 6f 00 73 00 5c 00 67 00 72 00 75 00 62 00 78 00 36 00 34 00 2e 00 65 00 66 00 69 00 00 00 / 7f ff 04 00
Boot0004* Diskette Drive        BBS(Floppy,Diskette Drive,0x0)AMBO
      dp: 05 01 17 00 01 00 00 00 44 69 73 6b 65 74 74 65 20 44 72 69 76 65 00 / 7f ff 04 00
    data: 41 4d 42 4f
Boot0006* USB Storage Device    BBS(USB,USB Storage Device,0x0)AMBO
      dp: 05 01 1b 00 05 00 00 00 55 53 42 20 53 74 6f 72 61 67 65 20 44 65 76 69 63 65 00 / 7f ff 04 00
    data: 41 4d 42 4f
Boot0007* CD/DVD/CD-RW Drive    BBS(CDROM,CD/DVD/CD-RW Drive,0x0)AMBO
      dp: 05 01 1b 00 03 00 00 00 43 44 2f 44 56 44 2f 43 44 2d 52 57 20 44 72 69 76 65 00 / 7f ff 04 00
    data: 41 4d 42 4f
Boot0008* Onboard NIC   BBS(Network,IBA GE Slot 00C8 v1550,0x0)AMBO
      dp: 05 01 1f 00 06 00 00 00 49 42 41 20 47 45 20 53 6c 6f 74 20 30 30 43 38 20 76 31 35 35 30 00 / 7f ff 04 00
    data: 41 4d 42 4f
Boot000E* Internal HDD  BBS(HD,P0: Samsung SSD 840 EVO 500GB ,0x0)AMBO
      dp: 05 01 27 00 02 00 00 00 50 30 3a 20 53 61 6d 73 75 6e 67 20 53 53 44 20 38 34 30 20 45 56 4f 20 35 30 30 47 42 20 00 / 7f ff 04 00
    data: 41 4d 42 4f
Boot0012* System Device Bay     BBS(HD,P1: ST1000LM024 HN-M101MBB    ,0x0)AMBO
      dp: 05 01 27 00 02 00 00 00 50 31 3a 20 53 54 31 30 30 30 4c 4d 30 32 34 20 48 4e 2d 4d 31 30 31 4d 42 42 20 20 20 20 00 / 7f ff 04 00
    data: 41 4d 42 4f
Boot0015* Diskette Drive        BBS(Floppy,Diskette Drive,0x0)AMBO
      dp: 05 01 17 00 01 00 00 00 44 69 73 6b 65 74 74 65 20 44 72 69 76 65 00 / 7f ff 04 00
    data: 41 4d 42 4f
Boot0016* Onboard NIC(IPV6)     PciRoot(0x0)/Pci(0x19,0x0)/MAC(d4bed949cb66,0)/IPv6([::],0,Static,[::],[::],64)AMBO
      dp: 02 01 0c 00 d0 41 03 0a 00 00 00 00 / 01 01 06 00 00 19 / 03 0b 25 00 d4 be d9 49 cb 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 / 03 0d 3c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 / 7f ff 04 00
    data: 41 4d 42 4f
Boot0017* Onboard NIC(IPV4)     PciRoot(0x0)/Pci(0x19,0x0)/MAC(d4bed949cb66,0)/IPv4(0.0.0.0,0,DHCP,0.0.0.0,0.0.0.0,0.0.0.0)AMBO
      dp: 02 01 0c 00 d0 41 03 0a 00 00 00 00 / 01 01 06 00 00 19 / 03 0b 25 00 d4 be d9 49 cb 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 / 03 0c 1b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 / 7f ff 04 00
    data: 41 4d 42 4f

How can I fix this? The device is a Dell Latitude E6530 laptop from 2012, so it has one of the earlier UEFI implementations.

lrzl commented 5 months ago

This response is machine translation, please understand

Hi,I also encountered this problem. I found that the output of my computer's efibootmgr --verbose command was different from the project examples:

My output

efibootmgr --verbose                                                                                                                                                                                                                   
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0003,2001,0000,2002,2003
Boot0000* ubuntu        HD(1,GPT,525b6ddd-b38e-44ed-920e-51818dc5b505,0x800,0x82000)/\EFI\ubuntu\shimx64.efiRC
      dp: 04 01 2a 00 01 00 00 00 00 08 00 00 00 00 00 00 00 20 08 00 00 00 00 00 dd 6d 5b 52 8e b3 ed 44 92 0e 51 81 8d c5 b5 05 02 02 / 04 04 34 00 5c 00 45 00 46 00 49 00 5c 00 75 00 62 00 75 00 6e 00 74 00 75 00 5c 00 73 00 68 00 69 00 6d 00 78 00 36 00 34 00 2e 00 65 00 66 00 69 00 00 00 / 7f ff 04 00
    data: 52 43
Boot0001* ...
Boot0003* Windows Boot Manager  HD(2,GPT,690619cf-276a-4c66-b186-3830a1741b4b,0x8000,0x32000)/\EFI\Microsoft\Boot\bootmgfw.efi57494e444f5753000100000088000000780000004200430044004f0042004a004500430054003d007b00390064006500610038003600320063002d0035006300640064002d0034006500370030002d0061006300630031002d006600330032006200330034003400640034003700390035007d0000002d000100000010000000040000007fff0400
      dp: 04 01 2a 00 02 00 00 00 00 80 00 00 00 00 00 00 00 20 03 00 00 00 00 00 cf 19 06 69 6a 27 66 4c b1 86 38 30 a1 74 1b 4b 02 02 / 04 04 46 00 5c 00 45 00 46 00 49 00 5c 00 4d 00 69 00 63 00 72 00 6f 00 73 00 6f 00 66 00 74 00 5c 00 42 00 6f 00 6f 00 74 00 5c 00 62 00 6f 00 6f 00 74 00 6d 00 67 00 66 00 77 00 2e 00 65 00 66 00 69 00 00 00 / 7f ff 04 00
    data: 57 49 4e 44 4f 57 53 00 01 00 00 00 88 00 00 00 78 00 00 00 42 00 43 00 44 00 4f 00 42 00 4a 00 45 00 43 00 54 00 3d 00 7b 00 39 00 64 00 65 00 61 00 38 00 36 00 32 00 63 00 2d 00 35 00 63 00 64 00 64 00 2d 00 34 00 65 00 37 00 30 00 2d 00 61 00 63 00 63 00 31 00 2d 00 66 00 33 00 32 00 62 00 33 00 34 00 34 00 64 00 34 00 37 00 39 00 35 00 7d 00 00 00 2d 00 01 00 00 00 10 00 00 00 04 00 00 00 7f ff 04 00
Boot0004* ...

Project examples

$ efibootmgr --verbose
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0002,0001,0017,001B,0000,0016,0019,001A,0018
Boot0000  Windows Boot Manager  HD(1,MBR,0x5092863d,0x3cde8c,0x1340)/File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS...
Boot0001* ubuntu                HD(1,GPT,2ffcc127-f6ce-40f0-9932-d1dfd14e9462,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)
Boot0002* ubuntu                HD(1,GPT,cba13b09-d754-4d31-9719-369fa60928d1,0x800,0x100000)/File(\EFI\ubuntu\shimx64.efi)
Boot0010  ...

Their output formats are different:

So I solved this problem by changing the regular expression on line 129 of the script file from if [[ $efi_data_line =~ ^Boot([[:xdigit:]]{4})\*?[[:blank:]]+(.+)[[:blank:]]+HD\(([[:digit:]]+),[^,]+,([^,]+)[^\)]+\)/File\(([^\)]+)\) ]] ; then to if [[ $efi_data_line =~ ^Boot([[:xdigit:]]{4})\*?[[:blank:]]+(.+)[[:blank:]]+HD\(([[:digit:]]+),[^,]+,([^,]+)[^\)]+\)/([^\)]+) ]] ; then

s-n-ushakov commented 5 months ago

Hi @lrzl and thank you for you input.

Are you in a position to verify if a combined test statement works on your system? Something like this:

  if [[ $efi_data_line =~ ^Boot([[:xdigit:]]{4})\*?[[:blank:]]+(.+)[[:blank:]]+HD\(([[:digit:]]+),[^,]+,([^,]+)[^\)]+\)/File\(([^\)]+)\) ]] \
      || [[ $efi_data_line =~ ^Boot([[:xdigit:]]{4})\*?[[:blank:]]+(.+)[[:blank:]]+HD\(([[:digit:]]+),[^,]+,([^,]+)[^\)]+\)/([^\)]+) ]] ; then

And if yes, do you mind submitting a pull request and becoming an official contributor? :)

lrzl commented 5 months ago

Hi @lrzl and thank you for you input.

Are you in a position to verify if a combined test statement works on your system? Something like this:

  if [[ $efi_data_line =~ ^Boot([[:xdigit:]]{4})\*?[[:blank:]]+(.+)[[:blank:]]+HD\(([[:digit:]]+),[^,]+,([^,]+)[^\)]+\)/File\(([^\)]+)\) ]] \
      || [[ $efi_data_line =~ ^Boot([[:xdigit:]]{4})\*?[[:blank:]]+(.+)[[:blank:]]+HD\(([[:digit:]]+),[^,]+,([^,]+)[^\)]+\)/([^\)]+) ]] ; then

And if yes, do you mind submitting a pull request and becoming an official contributor? :)

This is a good suggestion, I will consider contributing compatible code