grub

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

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

This section is empty.

Types

type BootLabel added in v1.0.0

type BootLabel string

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

const (
	// BootA is a bootloader label.
	BootA BootLabel = "A"

	// BootB is a bootloader label.
	BootB BootLabel = "B"

	// ConfigPath is the path to the grub config.
	ConfigPath = constants.BootMountPoint + "/grub/grub.cfg"
)

func FlipBootLabel added in v1.0.0

func FlipBootLabel(e BootLabel) (BootLabel, error)

FlipBootLabel flips the boot entry, e.g. A -> B, B -> A.

func ParseBootLabel added in v1.0.0

func ParseBootLabel(name string) (BootLabel, error)

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

type Config added in v1.0.0

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

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

func Decode added in v1.0.0

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

Decode parses the grub configuration from the given bytes.

func NewConfig added in v1.0.0

func NewConfig(cmdline string) *Config

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

func Read added in v1.0.0

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

Read reads the grub configuration from the disk.

func (*Config) Encode added in v1.0.0

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

Encode writes the grub configuration to the given writer.

func (*Config) Install added in v1.0.0

func (c *Config) Install(bootDisk, arch string) error

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

func (*Config) Put added in v1.0.0

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

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

func (*Config) Write added in v1.0.0

func (c *Config) Write(path string) 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