s-n-ushakov / rename-efi-entry

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

ERROR : EFI label 'A' is related to partition 'X' that is not currently known to the system #8

Closed Sadi58 closed 11 months ago

Sadi58 commented 11 months ago

The output of the command sudo efibootmgr -verbose shows all three systems (Windows plus two Linux distros) installed on three different partitions like this: HD(1,GPT,a958d073-5719-47ca-b80c-f0e0f37f510e,0x800,0xfa000)/File(\EFI\..................... Apparently, this is the "Partition UUID" of "/dev/sda1" which is my FAT32 EFI partition with UUID F4CE-E33A. I just wanted to use this script to rename one of my EFI entries generated automatically, but I couldn't because the script throws error with the message above. I'll try doing it manually then: deleting that EFI boot entry, and adding it back manually.

s-n-ushakov commented 11 months ago

Hi @Sadi58 , and it's regretful that something is not working... May my first guess be correct, that the system you try to rename is located on a removable drive? Might it be that it gets connected differently from time to time? Are you in a position to supply output of the sfdisk -d /dev/sda1 command too, along with verbatim output of the sudo efibootmgr -verbose command, as well as the command you use to run the script and the script verbatim output? In case you are concerned about getting your data published here, you are welcome to consider emailing it to me directly, and my email is available in the script code comments. Otherwise I regret to say that I am not very optimistic about troubleshooting of our issue, as the information is too concise so far...

Sadi58 commented 11 months ago

Hi @s-n-ushakov , No, the system is not on a removable drive. As a matter of fact, I've only noticed now that partitions have two different UUIDs (i.e. "UUID" and "Partition UUID") as seen in the screenshot of KDE Partition Manager's Properties dialog box for my EFI (sda1) partition. Screenshot_2023-08-07_11-43-44 I don't know if this is something new or typical of GPT partitions etc. Therefore, I thought your script failed to recognize this.

Output of the command sudo sfdisk -d /dev/sda1:

label: dos
label-id: 0x00000000
device: /dev/sda1
unit: sectors
sector-size: 512

Output of the command sudo efibootmgr --verbose:

BootCurrent: 0003
Timeout: 1 seconds
BootOrder: 0003,0002,0001,0000,0004,0005,0006
Boot0000* Windows Boot Manager  HD(1,GPT,a958d073-5719-47ca-b80c-f0e0f37f510e,0x800,0xfa000)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...6................
Boot0001* KDE neon      HD(1,GPT,a958d073-5719-47ca-b80c-f0e0f37f510e,0x800,0xfa000)/File(\EFI\NEON\GRUBX64.EFI)
Boot0002* Kdebian       HD(1,GPT,a958d073-5719-47ca-b80c-f0e0f37f510e,0x800,0xfa000)/File(\EFI\KDEBIAN\SHIMX64.EFI)
Boot0003* Kdebian EFI   HD(1,GPT,a958d073-5719-47ca-b80c-f0e0f37f510e,0x800,0xfa000)/File(\VMLINUZ)r.o.o.t.=./.d.e.v./.s.d.a.3. .i.n.i.t.r.d.=./.i.n.i.t.r.d...i.m.g. .r.o. .m.i.t.i.g.a.t.i.o.n.s.=.o.f.f. .q.u.i.e.t. .s.p.l.a.s.h.
Boot0004* UEFI:CD/DVD Drive     BBS(129,,0x0)
Boot0005* UEFI:Removable Device BBS(130,,0x0)
Boot0006* UEFI:Network Device   BBS(131,,0x0)

It's strange; I see the last three efi boot entries for the first time without any external connection to removable devices etc. ;-) I also don't know why my first efi boot entry, Boot0003 (manually added for quicker startup, bypassing grub bootloader) has all those dots. ;-)

Funny thing is; when I entered the command sudo "./admin-rename-efi-entry.bash" Kdebian kdebian 0002 today (merely swapping the old and new names) the script didn't throw that error message, prompting me to change the name as expected:

The following commands are about to be executed:
  efibootmgr --bootnum 0002 --delete-bootnum
  efibootmgr --create --disk /dev/sda --part 1 --label 'kdebian' --loader \\EFI\\KDEBIAN\\SHIMX64.EFI
Execute these commands? [y/N]

In conclusion, why and how the script failed to work yesterday with the output ERROR : EFI label 'sda1' is related to partition 'a958d073-5719-47ca-b80c-f0e0f37f510e' that is not currently known to the system...... is a mystery to me, like many other one-off odd things. Maybe you can understand all this better, and find something for fine-tuning, maybe it just doesn't worth the time... Thanks...

s-n-ushakov commented 11 months ago

Hi @Sadi58 , and thank you for detailed response. Glad to know that the script has finally agreed to work for you :) To be frank, I currently have no ideas about possible reasons for you to receive the error message on your first attempt. Maybe further practice reveals something... Meanwhile I see that your arrangements are somehow different from mine. In particular, you have three Linux installations in one partition, and this is the case I probably did not test against. Could you kindly check if the script agrees to rename any/all of your three systems/entries, and produces sane commands to be executed in all three cases? Thanks in advance... :)

Sadi58 commented 11 months ago

@s-n-ushakov No, I don't have three installations in one partition. "Partition UUID" a958d073-5719-47ca-b80c-f0e0f37f510e is the EFI system partition (sda1) of my laptop that came pre-installed with Windows 10. I have now two Linux distros in two partitions sharing another partition as /home). EFI boot entry named "Kdebian EFI" is merely a manual addition that boots directly into my current primary OS, Debian with KDE Plasma DE, bypassing the GRUB2 bootloader.

My guess is; it was probably one in a million chance that the script somehow failed to recognize that EFI system partition, and probably I'll never see it happen again, and we'll never know how come it happened. ;-)

s-n-ushakov commented 11 months ago

@Sadi58 Hi and thank you for your further comments. There is still something I cannot understand about your boot entries and systems :) I see three entries in your sudo efibootmgr --verbose output that all refer to the a958d073-5719-47ca-b80c-f0e0f37f510e partition. They are Boot0001* KDE neon, Boot0002* Kdebian and Boot0003* Kdebian EFI. And they all refer to different bootstrap folders: \EFI\NEON\GRUBX64.EFI, \EFI\KDEBIAN\SHIMX64.EFI and \VMLINUZ. Could you shed a bit of more light on these entries just for my curiosity? :) What can they be related to, if not to different OS installations, maybe some of them being obsolete? And do you see all of them in your boot menu? Or only a subset of them? And I've got an idea regarding the dots related to your Boot0003 entry. My guess is that this is how some UTF-16 flavor manifests itself. At least this looks probable... :)

Sadi58 commented 11 months ago

My laptop has one SDD disk with many partititions. sda1: EFI system partition (FAT32, Partition UUID: a958d073-5719-47ca-b80c-f0e0f37f510e, UUID: F4CE-E33A) containing an "EFI" directory containing subdirs "BOOT", "kdebian", "Microsoft", "neon" and "ubuntu" (this comes with neon efi grub installation somehow). In the root of this partition, I have manually copied "vmlinuz" and "initrd.img" from my Kdebian system in order to boot directly. sda2: Windows 10 partition sda3: Kdebian root partition sda4: Home partition (/home) used by both Kdebian and KDE neon. sda5: KDE neon root partition sda6: Data partition for my folders Documents, Downloads, Music, Pictures and Videos and so on... :-) So, when I boot normally via Boot2 (Kdebian) or Boot0001 (KDE neon), "/EFI/kdebian/shimx64.efi" or "/EFI/neon/grubx64.efi" launches Grub2 installed in sda3 or sda5, respectively. And when I boot via Boot3 (Kdebian EFI), which is like a substitute of Kdebian Grub2 entry, it directly boots my Kdebian system in sda3 using sda3 as root. I hope I've been clear enough.

s-n-ushakov commented 11 months ago

Thank you @Sadi58 , it is more clear now :)