Skip to main content

minaki

MinakiLabs command-line tools: one install, one command. Version 0.1 ships one command, minaki grub, a read-only check that your GRUB config can boot.

pip install minaki        # not on PyPI yet; for now: pip install .  (from a clone)
minaki grub check
minaki grub pin
minaki --help

Targets Ubuntu 24.04 first, and also Ubuntu 20.04, 22.04 and 26.04 and Debian 12. It needs Python 3.8 or newer and only the standard library. It reads files and runs grub-script-check (Debian/Ubuntu package grub-common). Run it as root, since grub.cfg is often readable only by root.

minaki grub check

check reads /boot/grub/grub.cfg once and runs every check on that one copy:

Check Fails when
exists the file is missing (and GRUB is installed), or cannot be read
size the file is empty (--min-size BYTES raises the floor)
no-nul-bytes the file has NUL bytes, as a file zero-filled after a crash does
menuentry there is no menuentry line, so GRUB has nothing to boot
sections a ### BEGIN /etc/grub.d/... ### section written by grub-mkconfig never reaches its ### END
grub-script-check grub-script-check rejects the file (it gets the same bytes on stdin)

The required checks are: the file exists, is not empty, has a menuentry, and grub-script-check accepts it. Two more checks are added. no-nul-bytes catches a file that was zero-filled after a crash. sections catches a file that grub-mkconfig started but that ends before a section it opened is closed. A hand-written config with no section markers skips that check.

Exit codes:

Code Meaning
0 every check passed
1 the file is bad (the output names what failed and where the last-good copy is)
2 could not check: bad usage, grub-script-check missing, permission denied, or not applicable

On a system that boots with systemd-boot, or that has no GRUB at all, there is no GRUB config to check. check then reports NOT APPLICABLE, exits 2, and does not crash.

It also warns, without failing, when a grub-mkconfig or update-grub is running at that moment (read from /proc) or when grub.cfg.new exists. Either one means the file may be in the middle of being written.

A healthy Ubuntu 24.04 system (real output from a lab VM):

$ sudo minaki grub check
minaki 0.1.0 grub check: /boot/grub/grub.cfg
  PASS   exists             7918 bytes, modified 2026-11-30T05:22:46Z
  PASS   size               7918 bytes, not empty
  PASS   no-nul-bytes       no NUL bytes
  PASS   menuentry          6 menuentry lines
  PASS   sections           12 generated sections, all closed
  PASS   grub-script-check  /usr/bin/grub-script-check exit 0
Result: OK (exit 0)

A syntax error:

$ sudo minaki grub check
minaki 0.1.0 grub check: /boot/grub/grub.cfg
  PASS   exists             7917 bytes, modified 2026-11-30T05:23:16Z
  PASS   size               7917 bytes, not empty
  PASS   no-nul-bytes       no NUL bytes
  PASS   menuentry          6 menuentry lines
  PASS   sections           12 generated sections, all closed
  FAIL   grub-script-check  exit 1: Syntax error at line 54
Result: FAILED: grub-script-check (exit 1)
Last good copy: /var/lib/minaki/grub.cfg.last (pinned 2026-11-30T05:23:16Z, 7918 bytes, sha256 04b7dfc37181d1d8)

minaki grub pin

pin runs check. If every check passes, it saves those exact bytes to /var/lib/minaki/grub.cfg.last, with a small grub.cfg.last.json holding the sha256, size and time. Because it writes the bytes it checked, a file that changes in between can never be pinned unchecked. The directory is mode 0700 and the files are 0600, since a GRUB config can hold password hashes. If the copy already matches, it reports unchanged. If check fails, nothing is written and the old last-good copy stays. It refuses a state directory under /boot.

A good time to pin is after a kernel update that booted fine.

If check fails, run sudo update-grub once, with no other package manager or update-grub running, then run minaki grub check again. The last-good copy is there to compare against, or to restore by hand as a last resort. Before you restore it, read it: it may name kernels that have since been removed.

--json

Both commands take --json and print one object:

{
  "tool": "minaki", "plugin": "grub", "version": "0.1.0", "command": "check",
  "status": "ok | failed | error | not_applicable", "exit_code": 0,
  "config": {"path": "/boot/grub/grub.cfg", "size": 9123, "sha256": "...", "mtime": "..."},
  "checks": [{"name": "exists", "status": "pass | fail | skip | error", "detail": "..."}],
  "failed": [], "errors": [], "warnings": [], "writers": [],
  "last_good": {"path": "/var/lib/minaki/grub.cfg.last", "sha256": "...", "pinned_at": "...", "matches_current": true}
}

pin adds pinned (true/false) and pin_detail.

What it never does

  • It never writes to /boot. It never runs update-grub, grub-mkconfig or grub-install, and never installs wrappers or hooks.
  • It never touches the network: no telemetry, no update check, no account.
  • It has no mode that runs two GRUB config writers at once. It reports on the race below; it is not a way to reproduce it.

What it does read: grub.cfg, /proc/*/cmdline (to spot running writers), and the usual ESP paths (to spot systemd-boot). What it runs: grub-script-check, which reads the config on stdin.

The concurrent update-grub race

Two GRUB config writers running at the same time (for example a package hook and a snapshot daemon, or two services at boot, each running update-grub or grub-mkconfig) can leave the boot config broken or missing. Public reports of this class of problem:

  • grub-btrfs issue #288 (2023): with grub-btrfsd running, a config rebuild during a pacman update failed with "cannot open `/boot/grub/grub.cfg.new'". The reporter suspected the daemon and the package hook were rebuilding at the same time.
  • TrueNAS middleware commit a50f509 (May 2026): two boot-time listeners both ran grub-mkconfig at the same time, "racing on /boot/grub/grub.cfg.tmp(.new)". The fix left one writer.
  • Launchpad #396381 (2009): update-grub ran twice during one package operation; the report suggests a dpkg trigger so it runs once.

minaki grub does not prevent this race. It tells you whether the file on disk right now will boot, and keeps a copy of the last one that passed.

Plugins

minaki parses only its own flags (--help, --version, --plugins) and the command name. Everything after minaki <command> goes to that command unchanged. Commands are plugins registered on the Python entry-point group minaki.plugins. The core asks that group what is installed and never imports a plugin by name.

Every plugin MinakiLabs writes ships inside the minaki package, so pip install minaki gets all of them. Anyone can publish their own minaki-<something> package that depends on minaki and registers on the same group. There is no plugin store, downloader or auto-install.

Plugins build on a small SDK, minaki.sdk: an optional base class, the exit codes, an argument parser named minaki <name>, and the standard --json. The plugin API is versioned (now 1); a plugin that needs a newer API is refused with a message to upgrade. minaki --plugins [--json] lists every registered plugin, where it came from, and whether it loads.

If two packages register the same name, the one inside minaki wins, and minaki --help shows the clash. A plugin that fails to load is listed with its error, and the other commands still work.

Development

python3 -m unittest discover -s tests -v     # standard library only

The real grub-script-check tests run when grub-common is installed. CI runs the suite inside Ubuntu 20.04, 22.04, 24.04 and 26.04 and Debian 12 containers, as root and as a normal user. tests/lab/ holds the scripts we run on throwaway VMs. Those scripts break grub.cfg on purpose, so never run them on a machine you care about.

Tested on

Every case on a throwaway VM, 2026-11-30, minaki 0.1.0 installed from the wheel. The cases: the real generated config passes, both as text and as JSON. pin, then pin again, which reports unchanged. /boot is unchanged by the tool, and the pinned copy is mode 0600 and byte-identical. Then the harness breaks the file: empty, cut in half, cut at a clean line, syntax error, zero-filled, missing, grub.cfg.new present, and grub-script-check removed. A run as nobody, one real update-grub, and a final restore that is byte-identical close it out. On the systemd-boot VM, check and pin report not applicable.

System Kernel Python Lab cases
Ubuntu 20.04 5.4.0-216-generic 3.8.10 30 of 30 passed
Ubuntu 22.04 5.15.0-203-generic 3.10.12 30 of 30 passed
Ubuntu 24.04 6.8.0-147-generic 3.12.3 30 of 30 passed
Ubuntu 26.04 7.0.0-43-generic 3.14.4 30 of 30 passed
Debian 12 6.1.0-56-cloud-amd64 3.11.2 30 of 30 passed
Ubuntu 24.04, UEFI, systemd-boot, GRUB removed 6.8.0-151-generic 3.12.3 6 of 6 passed

License

Apache-2.0. Copyright 2026 MinakiLabs LLC. See LICENSE.

This checks the bootloader file and does not remove packages; Minaki Tuner (minakilabs.com/tuner) is the product that does.

Metadata

Release files for minaki 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for minaki 0.1.0
File Size Uploaded Provenance Actions
minaki-0.1.0.tar.gz 30.1 kB With provenance Details for minaki-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for minaki 0.1.0
File Interpreter ABI Platform Actions
minaki-0.1.0-py3-none-any.whl Python 3 none any Details for minaki-0.1.0-py3-none-any.whl

Total release size: 53.7 kB

Release files / minaki-0.1.0.tar.gz

Download URL minaki-0.1.0.tar.gz
Size 30.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d6de4032e81cb1e31cf489b202f8e00facec886fefa8c3706df4c47b5a8baea7
BLAKE2b-256 checksum
How to use checksums
ca5e1b66cdccbacaf95e3c7a6a5871fcbed033941eb32c5927f0694b94a56b18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / minaki-0.1.0-py3-none-any.whl

Download URL minaki-0.1.0-py3-none-any.whl
Size 23.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da523337d0066630ab6df256cadcd20e678afbaa4c8382c3c40c16589c11910e
BLAKE2b-256 checksum
How to use checksums
09d4e1eede7dc95ff9a18de7f8ae09f9092477cb1dc0c845bfb4ad2fde2469db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for minaki 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for minaki-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page