A reader and resolver for GRUB boot configuration on Linux hosts:
grub.cfg, /etc/default/grub, and grubenv. It answers "which entry would
GRUB boot, with what cmdline?" and detects drift between the generated menu and
the operator config.
Status: Proxmox-focused today. It's validated against PVE's grub-mkconfig
output and best-effort elsewhere. See ROADMAP.md for the path to a
universal, cross-distro boot-entry reader (grub.cfg + BLS + systemd-boot).
| File | Module | Public entry |
|---|---|---|
/boot/grub/grub.cfg |
parser |
parse_grub_cfg |
/etc/default/grub |
default_grub |
parse_default_grub |
/boot/grub/grubenv |
grubenv |
parse_grubenv |
- "Which menuentry would GRUB boot right now?"
resolve_defaultties all three inputs together and applies GRUB's own selection rules:next_entryone-shot wins; thenGRUB_DEFAULT=savedroutes through grubenv; then numeric index or literal id; else fall back to entry 0. - "Is the kernel cmdline in grub.cfg consistent with what
/etc/default/grubdeclares?"compare_cmdlinereports drift in both directions, ignoringroot=andro/rwwhichupdate-grubinjects from the live mount table rather thanGRUB_CMDLINE_*. - "What kernels does GRUB know about?"
GrubCfg::kernel_versionsandGrubCfg::entry_by_kernel_versiongive the install tool a stable view of the boot menu independent of menu numbering.
lamboot-reader ships with the crate. Subcommands all accept
--json for machine-readable output and default to the standard
Proxmox/Debian paths (/boot/grub/grub.cfg, /etc/default/grub,
/boot/grub/grubenv):
lamboot-reader list-kernels # enumerate all menuentries
lamboot-reader default # show the entry GRUB would boot
lamboot-reader cmdline # cmdline of the default entry
lamboot-reader cmdline --kernel 6.17.13-11-pve
lamboot-reader compare-cmdline # drift detection; exits 2 on drift
lamboot-reader parse-default-grub # GRUB_CMDLINE_*, GRUB_DEFAULT, ...
lamboot-reader grubenv # saved_entry, next_entry, recordfail
Exit codes: 0 success, 1 input error, 2 operation found drift
(for compare-cmdline), 3 internal error.
Proxmox-focused. The parser handles the canonical Proxmox VE
grub-mkconfig output (one top-level menuentry, one "Advanced options"
submenu of per-kernel + recovery entries, plus the 20_memtest86+ and
30_uefi-firmware entries) but does not implement the full GRUB
config language. Specifically:
linux/linuxefiandinitrd/initrdefiare accepted as synonyms.submenublocks recurse; nested submenus would also work.set <var>=<value>at top level populatesGrubCfg::variables.configfile,multiboot{,2},module{,2},devicetreedirectives surface asGrubCfgError::Unsupported. They signal a config shape the parser doesn't handle yet, and the operator should know.- Unknown directives (
load_video,insmod,search,echo, …) are silently skipped.
The fixtures in tests/fixtures/ are written for the tests, in the
shape of a Proxmox VE host's files, and they're the canonical statement
of what's supported. To cover another distribution, write a fixture in
the shape of its grub.cfg and add a test case to src/parser.rs. Don't
copy a generated grub.cfg or a stock /etc/default/grub: Both carry
GNU GRUB's text, which is GPL-3.0-or-later, and this crate is MIT OR
Apache-2.0.
Licensed under either of MIT (LICENSE-MIT) or Apache-2.0 (LICENSE-APACHE) at your option.