bootloader

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package bootloader provides a unified interface for bootloader management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BootConfig

type BootConfig struct {
	KernelPath   string
	InitrdPath   string
	Cmdline      string
	DefaultEntry string
}

BootConfig holds kernel parameters for bootloader configuration.

type BootEntry

type BootEntry struct {
	Title  string
	Kernel string
	Initrd string
	Args   string
}

BootEntry describes a bootloader menu entry.

type Bootloader

type Bootloader interface {
	// Install sets up the bootloader on the target disk.
	Install(ctx context.Context, rootPath, diskDevice string) error
	// Configure sets kernel parameters and default entry.
	Configure(ctx context.Context, rootPath string, cfg BootConfig) error
	// ListEntries returns the available boot entries.
	ListEntries(ctx context.Context, rootPath string) ([]BootEntry, error)
	// SetDefault sets the default boot entry by title.
	SetDefault(ctx context.Context, rootPath, title string) error
}

Bootloader defines operations for managing a bootloader.

func DetectBootloader

func DetectBootloader(rootPath string) Bootloader

DetectBootloader examines rootPath and returns the appropriate Bootloader. It checks for the systemd-boot binary specifically; BOOTX64.EFI is not used because on most systems it is the shim loader (Secure Boot), not systemd-boot.

type GRUB

type GRUB struct{}

GRUB manages GRUB2 bootloader installation and configuration.

func (*GRUB) Configure

func (g *GRUB) Configure(ctx context.Context, rootPath string, cfg BootConfig) error

Configure sets the default boot entry and kernel command line.

func (*GRUB) Install

func (g *GRUB) Install(ctx context.Context, rootPath, diskDevice string) error

Install installs GRUB onto diskDevice targeting rootPath.

func (*GRUB) ListEntries

func (g *GRUB) ListEntries(_ context.Context, rootPath string) ([]BootEntry, error)

ListEntries returns parsed GRUB menu entries from grub.cfg.

func (*GRUB) SetDefault

func (g *GRUB) SetDefault(ctx context.Context, rootPath, title string) error

SetDefault sets a GRUB default entry by title.

type SystemdBoot

type SystemdBoot struct{}

SystemdBoot manages systemd-boot bootloader.

func (*SystemdBoot) Configure

func (s *SystemdBoot) Configure(_ context.Context, _ string, _ BootConfig) error

Configure is currently a no-op for systemd-boot (uses Type #1 BLS entries).

func (*SystemdBoot) Install

func (s *SystemdBoot) Install(ctx context.Context, rootPath, _ string) error

Install installs systemd-boot into the ESP at rootPath.

func (*SystemdBoot) ListEntries

func (s *SystemdBoot) ListEntries(ctx context.Context, rootPath string) ([]BootEntry, error)

ListEntries enumerates boot entries via bootctl.

func (*SystemdBoot) SetDefault

func (s *SystemdBoot) SetDefault(ctx context.Context, rootPath, title string) error

SetDefault sets the default boot entry via bootctl.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL