Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsEFIBooted ¶
func IsEFIBooted() bool
IsEFIBooted checks that the machine is booted in EFI mode and that the efivars filesystem is readable.
func ReadBootEntries ¶
ReadBootEntries reads all existing EFI boot entries, even if they are not in the boot order.
func WriteBootEntries ¶
WriteBootEntries overwrites or creates the specified EFI boot entries. It does not modify or delete any other boot entries.
func WriteBootOrder ¶
WriteBootOrder overwrites the EFI boot order variable.
Types ¶
type BootEntry ¶
type BootEntry struct { Description string // eg. "Linux Boot Manager" Path string // eg. `\EFI\systemd\systemd-bootx64.efi` PartitionGUID gpt.Guid PartitionNumber uint32 // Starts with 1 PartitionStart uint64 // LBA PartitionSize uint64 // LBA }
BootEntry represents a subset of the contents of a Boot#### EFI variable.
func NewBootEntry ¶
NewBootEntry creates a boot entry for softmetal by finding required information about the ESP partition on disk. The partitions argument should contain the final partitions stored on the disk, not the ones in the image. NewBootEntry fills all fields of BootEntry except Description. If there are n != 1 ESP partitions, NewBootEntry fails. ESP partitions are detected by their type: EFI System (see espGUIDStr).
func UnmarshalBootEntry ¶
UnmarshalBootEntry loads a BootEntry from its binary representation. WARNING: UnmarshalBootEntry only loads the Description field. Everything else is ignored (and not validated if possible)
type BootOrder ¶
type BootOrder []uint16
BootOrder represents the contents of the BootOrder EFI variable.
func ReadBootOrder ¶
ReadBootOrder reads the EFI boot order variable.
func UnmarshalBootOrder ¶
UnmarshalBootOrder loads a BootOrder from its binary representation.
type Update ¶
type Update struct { Write map[uint16]BootEntry // Create or update these variables Order BootOrder // Set BootOrder to this }
Update specifies a set of modifications to EFI boot variables.
func PlanUpdate ¶
func PlanUpdate(oldOrd BootOrder, oldEntries map[uint16]BootEntry, newEntry BootEntry) (*Update, error)
PlanUpdate creates or updates the softmetal boot entry to match newEntry and adjusts the boot order to have that entry load first. PlanUpdate does not write any EFI variables itself. The newEntry argument should be a fully configured boot entry with an empty description. If PlanUpdate plans to create a new boot entry, it uses the lowest free ID (Update.Write key). Only the Description field is required in the supplied boot entries (oldEntries). PlanUpdate recognizes the softmetal boot entry by description only. If there are multiple softmetal boot entries, PlanUpdate will fail.