Skip to main content

Python API to manage EFI Boot Entries

Project description

pyefiboot

Python Library to manage EFI Boot Entries

The aim of this library is to provide an API to the functionality of the efibootmgr (https://github.com/rhinstaller/efibootmgr) application. This provides a programmatic mechanism to read and update the EFI Boot Variables, allowing scripting of tasks to manage the EFI boot process.

[!NOTE] The initial release is a straightforward read-only solution, effectively mimicking the features of efibootmgr and efibootmgr -v calls.

Installation

When complete, should be:

pip install pyefiboot

Seek information elsewhere about installing in a virtual environment

This library currently has no dependencies

Usage

Most work can be done via the BootManager class which reads and provides access to all Boot related EFI variables

Reading current Boot Entries

import pyefiboot

bootmgr = pyefiboot.BootManager()

bootmgr.update_from_efi()

Printing to screen

To get output similar to efibootmgr:

bootmgr.display()

To get output similar to efibootmgr -v:

bootmgr.display(verbose=True)

Reading the BootCurrent, BootNext, BootTimeout and BootOrder EFI Variables

import pyefiboot

cur = pyefiboot.BootCurrent()

# Integer value of the current EFI Boot Entry
x: int = cur.value

# String representation of the current EFI Boot Entry, four character hex number
y: str = cur.hex_value

# BootNext and BootTimeout have similar functionality to BootCurrent

ord = pyefiboot.BootOrder()

# List of integers mapping the current programmed order of EFI Boot Entries
x: list[int] = ord.value

# String representation of the current EFI Boot Entry order, displayed as comma separated string of four character hex numbers
y: str = ord.hex_value

Creation of any of the above four classes will raise an exception if the nominated EFI variable does not exist

Reading an EFI Boot Entry variable

import pathlib
import pyefiboot

entry1 = pyefiboot.BootEntry(efivar_name='Boot0001')
entry2 = pyefiboot.BootEntry(efivar_fullpath=pathlib.Path('/sys/firmware/efi/efivars/Boot0002-8be4df61-93ca-11d2-aa0d-00e098032b8c'))

# Print string representation of boot entry to screen
print(entry1)

# Print verbose string representation of boot entry to screen
print(entry1.verbose_str())

# String representation of Boot Entry Index, four character hex number
x: str = entry2.entry_num

# If the Boot Entry refers to an actual local kernel to boot, returns the string representing the kernel file name, otherwise None
y: str | None = entry2.kernel_file

Access to other variables within the BootEntry will be in future versions

Logging

All modules within pyefiboot support Python logging, enabling logging and an appropriate log level in your application will allow these logs to be captured

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyefiboot-0.0.1.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyefiboot-0.0.1-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file pyefiboot-0.0.1.tar.gz.

File metadata

  • Download URL: pyefiboot-0.0.1.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyefiboot-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5ea42a2a457dcc7d2326fd466bb7323a7add9d0f1470e7854dcfa858f8aec7f2
MD5 afcecd72d7c4f00a0563f7a59356a067
BLAKE2b-256 f43943650ec72d26b7c3f95354bcb64b67c35ee8d43f30f1494d99bf9ed51ae5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyefiboot-0.0.1.tar.gz:

Publisher: python-publish.yml on jason-but/pyefiboot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyefiboot-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyefiboot-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 20.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyefiboot-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c173d7226e874b6e9f48cfc6e50f0cef3a08f9786f093f6a419165bdb999168e
MD5 64a30bf8e1911358c2c78065cd6f2f76
BLAKE2b-256 b0b00862c00fb95e9848b7b8b0f6d06fc0abc8055187fb510e17cc1497fe4516

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyefiboot-0.0.1-py3-none-any.whl:

Publisher: python-publish.yml on jason-but/pyefiboot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page