Skip to content

Merge GRUB cmdline instead of overwriting it (closes #19) - #30

Merged
VijitSingh97 merged 2 commits into
mainfrom
fix/grub-cmdline-merge
Jun 7, 2026
Merged

VijitSingh97 merged 2 commits into
mainfrom
fix/grub-cmdline-merge

Conversation

@VijitSingh97

Copy link
Copy Markdown
Contributor

Problem (#19 — boot-safety)

tune_kernel configured persistent HugePages by replacing the whole line:

sed -i 's|^GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT="$NEW_PARAMS"|'

$NEW_PARAMS is proposed-grub.sh's full string (quiet splash <hugepages/msr params>), so any other kernel parameters the user or distro had set were silently dropped — e.g. nomodeset, intel_iommu=on, amd_iommu=on, console=, root-fs flags. On the wrong box that's a failed/headless boot.

Fix

A pure, testable grub_merge_cmdline helper merges in only the params we own and preserves everything else:

  • keep every existing token except the ones we manage (hugepagesz=*, hugepages=*, default_hugepagesz=*, msr.allow_writes=*)
  • append the freshly-computed managed params
  • idempotent: re-running strips the previously-added managed params and re-adds the current ones, so an unchanged config is detected as "already configured" (no churn, no duplicate .bak)

tune_kernel now reads the current cmdline, computes the merge, and only rewrites when it actually changes (still backing up to .bak first).

Tests

  • Unit: grub_merge_cmdline preserves quiet/custom nomodeset, adds the HugePage/MSR params, is idempotent, and replaces (not accumulates) stale managed params.
  • E2E: asserts quiet splash is still present in /etc/default/grub after HugePage configuration (native Linux + Docker).

No Pithead/XMRig surface (host-local boot config). make test green; closes #19.

🤖 Generated with Claude Code

VijitSingh97 and others added 2 commits June 7, 2026 02:26
tune_kernel replaced GRUB_CMDLINE_LINUX_DEFAULT wholesale, dropping any other
kernel parameters the user/distro had set (a boot-safety risk). Add a pure
grub_merge_cmdline helper that preserves every existing param and replaces only
the HugePage/MSR params we manage (hugepagesz/hugepages/default_hugepagesz/
msr.allow_writes), and use it in tune_kernel. Idempotent: re-runs strip the old
managed params and re-add the current ones, so a stable config detects "already
configured" and makes no change.

Tests: unit tests for grub_merge_cmdline (preserve/replace/idempotent) and an
E2E assertion that "quiet splash" survives the HugePage configuration.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@VijitSingh97
VijitSingh97 merged commit fafeee5 into main Jun 7, 2026
3 checks passed
@VijitSingh97
VijitSingh97 deleted the fix/grub-cmdline-merge branch June 7, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GRUB cmdline overwritten wholesale — drops existing kernel params (boot-safety risk)

1 participant