All Projects → s-n-ushakov → rename-efi-entry

s-n-ushakov / rename-efi-entry

Licence: BSD-2-Clause, Unknown licenses found Licenses found BSD-2-Clause LICENSE.BSD Unknown LICENSE.LITL
A Bash script to rename EFI boot entries

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to rename-efi-entry

Efifs
EFI FileSystem drivers
Stars: ✭ 272 (+504.44%)
Mutual labels:  uefi, efi
Minimal
Minimal Linux Live (MLL) is a tiny educational Linux distribution, which is designed to be built from scratch by using a collection of automated shell scripts. Minimal Linux Live offers a core environment with just the Linux kernel, GNU C library, and Busybox userland utilities.
Stars: ✭ 1,014 (+2153.33%)
Mutual labels:  uefi, efi
Efiguard
Disable PatchGuard and DSE at boot time
Stars: ✭ 601 (+1235.56%)
Mutual labels:  uefi, efi
efi
efi headers
Stars: ✭ 24 (-46.67%)
Mutual labels:  uefi, efi
meta-secure-core
OpenEmbedded layer for the use cases on secure boot, integrity and encryption
Stars: ✭ 80 (+77.78%)
Mutual labels:  uefi, efi
edk2-nightly
Unofficial EDK2 nightly build
Stars: ✭ 20 (-55.56%)
Mutual labels:  uefi, efi
UefiToolsPkg
Various useful utilities for UEFI
Stars: ✭ 87 (+93.33%)
Mutual labels:  uefi, efi
efi-clang
Build UEFI applications with the Clang compiler and LLD linker.
Stars: ✭ 40 (-11.11%)
Mutual labels:  uefi, efi
Hackintosh-ASUS-A455LF-Notebook
EFI Folder for ASUS A455LF-WX039D Notebook Series with Clover/OpenCore Legacy or UEFI
Stars: ✭ 27 (-40%)
Mutual labels:  uefi, efi
Veracrypt Dcs
VeraCrypt EFI Bootloader for EFI Windows system encryption (LGPL)
Stars: ✭ 81 (+80%)
Mutual labels:  uefi, efi
Rust Uefi Runtime Driver
Template for UEFI runtime drivers written in Rust with serial logging and debugging support.
Stars: ✭ 21 (-53.33%)
Mutual labels:  uefi, efi
sicherboot
Unmaintained systemd-boot integration with secure boot support; consider https://github.com/Foxboron/sbctl instead.
Stars: ✭ 31 (-31.11%)
Mutual labels:  uefi, efi
Multibootusb
Create multiboot live Linux on a USB disk...
Stars: ✭ 1,042 (+2215.56%)
Mutual labels:  uefi, efi
efi
Ergonomic Rust framework for writing UEFI applications.
Stars: ✭ 44 (-2.22%)
Mutual labels:  uefi, efi
uefi-elf-bootloader
UEFI ELF Bootloader example
Stars: ✭ 40 (-11.11%)
Mutual labels:  uefi, efi
Hackintosh-Gigabyte-B460M-Aorus-Pro
Boot with OpenCore
Stars: ✭ 76 (+68.89%)
Mutual labels:  efi
Dell-Inspiron-7501-Hackintosh
Hackintosh for Dell Inspiron 750x/ Dell Vostro 750x
Stars: ✭ 18 (-60%)
Mutual labels:  efi
pipxe
iPXE for the Raspberry Pi
Stars: ✭ 154 (+242.22%)
Mutual labels:  uefi
ASRock-Z370-Fatal1ty-ITX-OpenCore-hackintosh
华擎 asrock z370 gaming itx opencore
Stars: ✭ 22 (-51.11%)
Mutual labels:  efi
designaire-z390-intel-i9-9900k-opencore
Gigabyte Designare z390 EFI - OpenCore
Stars: ✭ 154 (+242.22%)
Mutual labels:  efi

rename-efi-entry

A Bash script to rename EFI boot entries

Background

EFI / UEFI, boot configurations

EFI / UEFI is a specification that defines a software interface between an operating system and platform firmware. It is intended by hardware manufacturers to replace the legacy BIOS firmware interface.

In particular this specification allows to define OS boot configurations to be loaded / executed upon system power on. These boot configurations specify disk partitions to boot from, and are typically identified by their text labels that are listed in "Startup" / "Boot" EFI setup sections. These boot configurations may be optionally selectable upon system startup.

The problem

Operating system installation routines tend to have these boot configuration labels hard-coded and to create them in EFI PROM automatically. So in case a computer has, say, several Ubuntu instances installed, it is also likely to have several identical "ubuntu" boot configuration labels in its EFI menus, causing a kind of confusion.

One might further want to rename boot configurations, so to make them distinguishable, but unfortunately the standard efibootmgr utility has no option for that. It is only possible to delete a boot configuration entry and to re-create it with a new label. Meanwhile, the data that is necessary for re-creating a boot configuration entry is not trivial and requires certain inquiries into EFI configuration and disk partition attributes.

The script

The rename-efi-entry script is designed to help renaming EFI boot configuration entries using efibootmgr utility for entry deletion and re-creation. It automates querying current EFI configuration and bootable partition data, and also shaping command line arguments for efibootmgr.

Usage

sudo ./rename-efi-entry.bash existing_efi_label new_efi_label [bootnum]
Command line arguments

existing_efi_label

existing EFI entry label to be renamed;
a special value of '*' is recognized as a placeholder for "any label", in particular to be used in cases of missing label

new_efi_label

the new label value to be assigned

bootnum

conditionally optional: the bootnum value of the EFI entry to be renamed;
required in case of multiple matching label values, so to avoid ambiguity

E.g.:

sudo ./rename-efi-entry ubuntu 'ubuntu 18.04'

or in case of multiple boot entries labeled as 'ubuntu':

sudo ./rename-efi-entry ubuntu 'ubuntu 18.04' 0001

or in case of missing boot entry label in EFI menu:

sudo ./rename-efi-entry '*' 'ubuntu 18.04' 0001

In case of doubt bootnum values may be clarified using efibootmgr --verbose command, see entries like Boot0001* in the first column:

$ 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  ...

Required bootnum values (e.g. 0001 from Boot0001*) may be further identified by checking corresponding uuid values (e.g. 2ffcc127-f6ce-40f0-9932-d1dfd14e9462) against values provided by sfdisk -d command, e.g.:

$ sudo sfdisk -d /dev/sda
label: gpt
label-id: 0560DAA2-3010-47A2-B083-047C813F0A04
device: /dev/sda
unit: sectors
first-lba: 34
last-lba: 1953525134

/dev/sda1 : start=        2048, size=     1048576, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=2FFCC127-F6CE-40F0-9932-D1DFD14E9462, name="EFI System Partition"
/dev/sda2 : start=     1050624, size=   102400000, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=A06790C2-3818-4F57-84EF-4D1B9FFB417E, name="SSD system"
/dev/sda3 : start=   103450624, size=  1850073088, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=67A374C2-081E-477E-945C-78BE129A2044, name="SSD data"

Implementation details

What the script does under the hood, is:

  • obtain a list of disk devices using lsblk;

  • obtain a list of disk partitions and their uuid values for every disk device using sfdisk;

  • obtain a list of EFI boot entries using efibootmgr;

  • filter EFI boot entries against existing_efi_label value, supplied by the user as command line argument;

  • make sure that this boot entry identification is unique, using bootnum if necessary;

  • extract uuid value from the EFI boot entry to be renamed, and use it to identify the relevant disk partition and its device name;

  • verify matching of partition numbers between EFI boot entry and partition device name;

  • shape the commands for efibootmgr to delete the existing EFI boot entry and to create a new one with required label;

  • ask final user consent;

  • apply the efibootmgr commands.

Limitations

This script was designed to rename EFI boot entries that are related to Linux. It is likely to ignore the other ones. Still it is reported to deal with Windows 10 entries successfully too.

For an EFI boot entry to be renamed, the related device needs to be attached / known to the system currently running.

The following boot device types are recognized and honored (see Arch Linux : Device file : Block device names):

SCSI family

e.g. /dev/sda1

NVMe

e.g. /dev/nvme0n1p1

MMC family

e.g. /dev/mmcblk0p1

Important usage notes

Feel free to use, but do it on your risk :)

It may be wise to review the efibootmgr commands before final execution…​

Licenses

The project is issued and distributed under the following licenses:

More on LITL
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].