grub

package
v1.9.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package grub provides the interface to the GRUB bootloader: config management, installation, etc.

Package grub provides the interface to the GRUB bootloader: config management, installation, etc.

Package grub provides the interface to the GRUB bootloader: config management, installation, etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Quote added in v1.4.0

func Quote(s string) string

Quote according to (incomplete) GRUB quoting rules.

See https://www.gnu.org/software/grub/manual/grub/html_node/Shell_002dlike-scripting.html

func Unquote added in v1.4.0

func Unquote(s string) string

Unquote according to (incomplete) GRUB quoting rules.

Types

type BootLabel

type BootLabel string

BootLabel represents a boot label, e.g. A or B.

const (
	// ConfigPath is the path to the grub config.
	ConfigPath = constants.BootMountPoint + "/grub/grub.cfg"
	// BootA is a bootloader label.
	BootA BootLabel = "A"
	// BootB is a bootloader label.
	BootB BootLabel = "B"
	// BootReset is a bootloader label.
	BootReset BootLabel = "Reset"
)

func ParseBootLabel

func ParseBootLabel(name string) (BootLabel, error)

ParseBootLabel parses the given human-readable boot label to a BootLabel.

type Config

type Config struct {
	Default        BootLabel
	Fallback       BootLabel
	Entries        map[BootLabel]MenuEntry
	AddResetOption bool
}

Config represents a grub configuration file (grub.cfg).

func Decode

func Decode(c []byte) (*Config, error)

Decode parses the grub configuration from the given bytes.

func NewConfig

func NewConfig() *Config

NewConfig creates a new grub configuration (nothing is written to disk).

func Probe added in v1.5.0

func Probe(disk string, options options.ProbeOptions) (*Config, error)

Probe probes a block device for GRUB bootloader.

func ProbeWithCallback added in v1.8.0

func ProbeWithCallback(disk string, options options.ProbeOptions, callback func(*Config) error) (*Config, error)

ProbeWithCallback probes the GRUB bootloader, and calls the callback function with the Config.

func Read

func Read(path string) (*Config, error)

Read reads the grub configuration from the disk.

func (*Config) Encode

func (c *Config) Encode(wr io.Writer) error

Encode writes the grub configuration to the given writer.

func (*Config) Install

func (c *Config) Install(opts options.InstallOptions) (*options.InstallResult, error)

Install validates the grub configuration and writes it to the disk.

func (*Config) Put

func (c *Config) Put(entry BootLabel, cmdline, version string) error

Put puts a new menu entry to the grub config (nothing is written to disk).

func (*Config) RequiredPartitions added in v1.8.0

func (c *Config) RequiredPartitions() []partition.Options

RequiredPartitions returns the list of partitions required by the bootloader.

func (*Config) Revert added in v1.5.0

func (c *Config) Revert(disk string) error

Revert reverts the bootloader to the previous version.

func (*Config) Write

func (c *Config) Write(path string, printf func(string, ...any)) error

Write the grub configuration to the given file.

type MenuEntry struct {
	Name    string
	Linux   string
	Cmdline string
	Initrd  string
}

MenuEntry represents a grub menu entry in the grub config file.

Jump to

Keyboard shortcuts

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