Skip to content

vm: XFS v4 on LVM with an empty extra disk, and relocate onto it - #72

Merged
TusanHomichi merged 9 commits into
mainfrom
claude/project-thread-btwg94
Oct 13, 2026
Merged

TusanHomichi merged 9 commits into
mainfrom
claude/project-thread-btwg94

Conversation

@TusanHomichi

@TusanHomichi TusanHomichi commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Requested by Peter · project thread

This PR started stacked on #71. #71 is now merged, and this branch is rebased onto main (c3af630).

What this adds

Route: none. This PR changes the VM tier and adds relocate. Files: tools/vm.py, adapters/el.toml [relocate], tools/check.py and client/src/check.rs, the SPEC "VM tier" section plus a new "Relocate" section, and tools/test_relocate.py. The test is wired into wend check and into the client job, under EL7's bash 4.2.
New fixes: none.
Claims issue: none. This is steps 2 and 4 of docs/rebuild-and-carry.md, from #68.

Before: the VM tier installed every EL box on one disk with plain partitions. It couldn't make the machine rebuild-and-carry is for (CentOS 7 from 7.0-7.2 media, XFS v4 on LVM). Nothing could move such a machine's root onto a filesystem EL10 can mount.

After:

  • tools/vm.py --root-fs xfs-v4 --lvm --extra-disk 30 build el/centos7-lamp installs exactly that machine. The layout is anaconda's EL7 autopart: /boot, then one PV in VG centos holding swap and a root that fills it. Next to it sits an empty 30 GB disk that anaconda never touches.
  • tools/vm.py --root-fs xfs-v4 --lvm --extra-disk 30 relocate el/centos7-lamp runs relocate on a fresh copy of the box:
    • It copies the running root onto a new XFS v5 LV centos/wend-root on the extra disk and flips the boot to it for one trial.
    • It then proves six boots in turn:
      1. The trial boot comes up on the new root.
      2. A hard reset during the trial comes back on the old root, because the trial was one-shot.
      3. The trial runs again, on the new root.
      4. Commit plus a reboot gives the new root.
      5. A one-shot rollback gives the old root.
      6. One more reboot gives the new root.
    • After each boot it checks which root came up, plus the box's checks, its network and its firmware.

How:

  • Layouts are install choices, not boxes. A chroot box has no disks, so a centos7-lamp-xfsv4 box would just be a duplicate that every pinned fix fires on as a decoy.
  • Relocate's commands live in the adapter's [relocate] table, as harness steps fixes can't reach: preflight, GRUB refresh, place, copy, fixup, flip, release and cleanup, plus the commands run between boots.
    • Preflight refuses, with a reason, anything that isn't built yet: UEFI, a /boot that isn't a plain partition, a / that isn't on LVM, LUKS, other v4 filesystems, a pending kernel, or yum running. It also refuses a disk that isn't whole, empty, unmounted, not a PV and big enough.
    • GRUB refresh runs the 7.9 box's own grub2-install, before the copy.
    • The copy is rsync from a bind mount of /, in two passes. Services are stopped for the second pass, except sshd, NetworkManager, firewalld, auditd, dbus and systemd's own.
    • Fixup works on the copy. It changes the copy's fstab and its rd.lvm.lv, then in a chroot of the copy rebuilds a non-host-only initramfs for each kernel and runs grub2-mkconfig. Last, it fixes SELinux labels offline with setfiles -r.
    • The flip puts a stub grub.cfg on the old /boot, with its own wend_default and wend_next in grubenv. The stub saves and restores root and prefix for the fallback entry. The old root stays the default, arming the trial is the flip's last write, and fsfreeze follows.
  • One sandbox exception for review: the fixup chroot binds the machine's own /dev and mounts /proc and /sys. That happens only inside the machine being relocated, never on a box on a harness host. All three are unmounted before the step ends and checked against mountinfo.

Model

None: hand-written by Claude (claude-code).

Evidence

  • Real VM on remi, BIOS, at 02835c3: PASS on all six boots. Relocate itself took 146 s, and the new root used 1986 MiB. Before relocate, xfs_info showed crc=0 ftype=0 on / and /boot, on the LVM layout plus an empty 30 GB disk. That run used a 500 MiB /boot. vm: install EL7 boxes, choose the root filesystem, and boot guests on UEFI #71 has since made EL7's default 1 GiB. Relocate's size check measures what /boot uses, so nothing it relies on changed. The full write-up is in the comments here and on Routes don't test kernels, bootloaders or a real first boot #13.
  • python3 wend check passes.
  • tools/test_relocate.py passes under both modern bash and EL7's bash 4.2. It covers:
    • preflight accepting a default 7.0-7.2 install and refusing 17 machines, each with its own reason;
    • the copy's fstab and kernel line;
    • the flip, with the real grub-editenv and grub-script-check.
  • Client parity is identical.

Self-review (AGENTS.md step 5)

  • Every precondition is as narrow as I can make it, and ./wend verify found no decoy hits (no fixes)
  • Every fix fixes the real problem, not the symptom a check inspects (no fixes)
  • One problem per fix; load-bearing steps (like repair) kept (no fixes)
  • No edits to tools/, adapters/, SPEC.md, .github/, other boxes' roles, or other people's fixes: VM-tier and relocate spec change (tools/, adapters/el.toml, SPEC.md, the client job's test list)
  • Commits are signed off (git commit -s)

🤖 Generated with Claude Code

https://claude.ai/code/session_017K4daGyJmuJf8k4B9HJ7yw

@TusanHomichi TusanHomichi self-assigned this Oct 13, 2026
@github-actions github-actions Bot added the needs-claude-review Waiting on the Claude review layer label Oct 13, 2026
@TusanHomichi
TusanHomichi force-pushed the claude/project-thread-btwg94 branch from fc81471 to 88e3552 Compare October 13, 2026 15:06
@TusanHomichi TusanHomichi changed the title vm: LVM layout, XFS v4 and empty extra disks as install choices (stacked on #71) vm: XFS v4 on LVM with an empty extra disk, and relocate onto it (stacked on #71) Oct 13, 2026

Copy link
Copy Markdown
Member Author

Independent review: signed off at head b10ed4d. That covers 903a2ff, 88e3552 and b10ed4d. Diff reviewed: origin/claude/vm-uefi...HEAD.

This review covers the code only. The VM proof (tools/vm.py --root-fs xfs-v4 --lvm --extra-disk N relocate el/centos7-lamp) hasn't run yet and is waiting on remi.

What I checked:

  • python3 wend check passes, and so does python3 tools/test_relocate.py, with the real grub-editenv and grub-script-check.
  • client/parity.py against a release build of b10ed4d reports 151 checker cases (66 refused) and comes out identical to the Python side. The relocate key-set and type checks in check.rs match tools/check.py.
  • I traced the shell under set -e (run as sh, which is bash in POSIX mode on EL7). The only failures set -e lets through are commands in the middle of an && chain: pvcreate/vgextend in place, and the fstab awk line in fixup. A later command catches each one (the mkfs.xfs ... || exit 1 and the fstab verify), so a failed step never reports success.
  • The GRUB stub: load_env with a whitelist, then set wend_next= followed by save_env wend_next clears the one-shot before the entry is taken. With no one-shot set, it falls back to wend_default, which means the old root unless it says 0. Entry 0's set prefix= carries into configfile because prefix and root are exported. Entry 1 reaches /grub2/grub.cfg.wend-old through the old $root. Arming is the last write, and fsfreeze follows.
  • The chroot in fixup binds /dev non-recursively and mounts a fresh /proc and /sys. An EXIT trap unmounts them, the mountinfo check runs before setfiles, and cleanup unmounts them again.
  • The rsync exclude /boot/* is anchored and protects those files from --delete. The bind of / doesn't recurse into other mounts.
  • vm.py: vdb/sdb is derived from the first disk, extra disks get overlays per hop, the system_reset goes through the monitor socket, and the stage order matches SPEC. The build cache key for the default layout is unchanged.
  • Sandbox exception: [relocate] is read only by tools/vm.py relocate. No fix, op or compile path, and nothing in the client, reaches it.

Non-blocking nits:

  1. adapters/el.toml stub: there's no set fallback=1. If entry 0 fails inside GRUB (the search or the configfile), GRUB waits at the menu with the timeout unset. A power cycle still lands on the old root, so this is safe, but a remote machine would sit there.
  2. Separate filesystems that aren't XFS v4 (an ext4 or v5 /var or /home) aren't copied. Both roots keep their fstab lines and mount them, so writes during the trial land on the old machine's data too. Preflight allows this, so either refuse it or say so in SPEC.
  3. While the stub is in charge, a kernel update on the old root (grubby, or grub2-mkconfig through /etc/grub2.cfg) edits or overwrites the stub. This is worth adding to "Not built yet".
  4. fixup: a dropped kernel's vmlinuz is moved aside, but the kernel package is still installed in the copy, so rpm -V flags it. Also, $VG/$OLD_LV go into the sed regex unescaped (a . is a wildcard). Both are cosmetic.

Generated by Claude Code

Copy link
Copy Markdown
Member Author

Follow-up sign-off at head ca58800. This extends the earlier sign-off at b10ed4d.

I reviewed the changes since b10ed4d (b10ed4d..ca58800, commits 0a7bc4a and ca58800). Both are clean:

  • Preflight check for other mounts: the new check refuses any other filesystem mounted from a /dev source. It can't trip set -e early. I ran it on a host with extra disk-backed mounts and it refused correctly, and it also passes the shimmed tests.
  • Escaped VG/LV names: I ran the fixup text with VG=vg.1. Only rd.lvm.lv=vg.1/root was rewritten; vgx1/root and vg.1/swap were left alone.
  • SPEC note: the note about holding kernel installs between the flip and commit is fine.

I checked the stub's fallback in grub-emu. I extracted the exact stub from the flip script (only timeout=3 changed to 0, because emu's countdown doesn't run without a tty). The old /boot and the new root were disk images mapped through device.map, so search and save_env ran against real devices:

Scenario Result
search finds the new root but its grub.cfg can't be read falls back to entry 1, which reaches the old config with root=hd0, prefix=(hd0)/grub2
search fails the same
wend_next=0 new root, with prefix set there; save_env cleared wend_next
wend_next=1 old root; wend_next cleared
wend_default=0 new root
wend_default=1, nothing set at all, or wend_next empty (after the one-shot) old root

grub-emu here is GRUB 2.12, not EL7's 2.02beta2. The stub only uses commands that 2.02beta2 also has.

python3 wend check, python3 tools/test_relocate.py and client/parity.py all pass; parity is identical.

As before, this review covers the code only. The VM proof is waiting on remi. The one leftover nit is cosmetic: when a kernel is dropped from the copy, its package stays installed there.


Generated by Claude Code

Copy link
Copy Markdown
Member Author

Follow-up sign-off at head 02835c3.

Since ca58800 (the head remi ran), two things changed: QEMU's monitor socket path, and the preflight's case pattern for bash 4.2 along with its test. I reviewed ca58800..02835c3 and found nothing blocking.

  • Case pattern: the new (/dev/*) pattern parses in bash 4.2.0. The old pattern fails there with "unexpected token `;;'", which is remi's error.
  • Parsing every relocate script under bash 4.2: WEND_EL7_BASH=<bash 4.2> python3 tools/test_relocate.py passes, and every relocate script parses. That covers each step in the exact file form run_hop sends to the guest (the ENV prefix and --posix, as sh runs it), plus booted, arm, commit_trial, rollback_next and the runner. wend check and the plain-sh run of the test also pass.
  • Monitor socket: the socket now lives in its own mkdtemp directory, created in start(). A guest is added to GUESTS only after that directory exists, so main's finally never sees a guest that was never started (for example the one replay creates only to read the boot id). No guest is started twice. The other monitor_path user is reset(), which runs only on a started guest. The path is now about 30 bytes, well inside the 108-byte limit.
  • Workflow: the pinned sha256 matches the ftp.gnu.org bash-4.2.tar.gz, and the tarball's .sig verifies against Chet Ramey's key (fingerprint 7C01 35FB 088A AF6C 66C6 50B9 BB58 69F0 64EA 74AB). The step's exact configure/make line builds with GCC 13.3, the same compiler as ubuntu-24.04. A failed build fails the step.
    • Nit: there's no apt-get update before apt-get install grub-common, so a stale runner index could 404.

As before, this review covers the code only. The VM proof is pending a rerun on remi.


Generated by Claude Code

@TusanHomichi
TusanHomichi force-pushed the claude/project-thread-btwg94 branch from 02835c3 to 9d49758 Compare October 13, 2026 16:51

Copy link
Copy Markdown
Member Author

Relocate VM proof (BIOS): PASS at 02835c3

remi ran tools/vm.py --root-fs xfs-v4 --lvm --extra-disk 30 relocate el/centos7-lamp from a normal checkout path. This is a maintainer-run proof, not CI.

Box:

  • Built by the 7.9 kickstart and passed its own checks.
  • Inside the guest, xfs_info shows the 7.0–7.2 format on both / (/dev/mapper/centos-root) and /boot (vda1): crc=0 finobt=0 ftype=0 isize=256.
  • lsblk: vda1 500M on /boot; vda2 holds LVM centos-root 28.5G and swap 1G; vdb 30G empty.
Stage Wanted Came up on
relocate (preflight, GRUB refresh, place, copy, fixup, flip) OK OK in 146 s
trial boot new root new
hard reset from QEMU's monitor during the trial old root (one-shot) old
trial again new new
commit to the trial, reboot new (default) new
one-shot rollback old old
reboot after the rollback new new

Nothing was forced, no checks were lost, and the network was kept at every stage. The new root uses 1986 MiB. run.json says result: pass with layout {root_fs: xfs-v4, lvm: true, extra_disks: [30]} and new disk /dev/vdb. remi's run dir is .wend/vm/20261013-093841-el_centos7-lamp-bios-xfs-v4-lvm-x1-relocate-3893614.

Run 1, at ca58800, found two bugs, both fixed before this run:

  • QEMU's monitor socket path was over the 108-byte limit.
  • The preflight had a case pattern that CentOS 7's bash 4.2 can't parse inside $( ). The relocate tests now parse and run every script under bash 4.2 in CI.

Since the proven head: the branch is rebased onto #71's a786be5, now head 9d49758. The [relocate] table and relocate() in vm.py are byte-identical to 02835c3. The only layout change comes from #71: /boot is now boot_part_mib (1 GiB, 7.9's installer default) instead of 500 MB. A 7.0–7.2 install made 500 MB, so a later run on a 7.0–7.2-sized /boot may want to set that explicitly. Relocate doesn't depend on the size.

Not proven here: UEFI, relocate followed by the route to Alma 10 (waits on #75 and the EL8+ BIOS grub2-install step), and a 7.0-media core.img, which needs the GRUB refresh to actually matter.


Generated by Claude Code

Copy link
Copy Markdown
Member Author

Sign-off on the rebased series at head 9d49758, on top of #71's a786be5.

I reviewed origin/claude/vm-uefi...HEAD and ran git range-diff against the old series (through 02835c3). I found nothing blocking.

  • Conflict resolutions: relocate is added next to main's runtimes in ADAPTER_KEYS, in both tools/check.py and client/src/check.rs. The relocate mutations sit beside the runtimes ones in tools/test_check.py. wend check runs test_esm_pins and test_relocate and returns ... or e or r. Every other commit has no changes in the range-diff.
  • 9d49758: this commit only renames boot_mib to boot_part_mib in the layout's part /boot line. The PR's vm.py patch is otherwise identical to 02835c3's.
  • Relocate code: the [relocate] table (compared as parsed TOML), tools/test_relocate.py and the workflow step are identical to 02835c3.
  • What relocate depends on in vm: install EL7 boxes, choose the root filesystem, and boot guests on UEFI #71: I checked run_hop, Guest, checks, backends.fill and the stub's inputs, and none of them changed. The one change that reaches relocate is that the VM box's /boot is now 1 GiB (boot_part_mib = 1024) instead of 500 MiB. Relocate measures what /boot uses, not the partition size, so this doesn't affect its logic. remi's passing proof at 02835c3 was on the old 500 MiB layout.
  • Tests: python3 wend check passes, WEND_EL7_BASH=<bash 4.2> python3 tools/test_relocate.py passes, and tools/test_check.py passes. client/parity.py against a fresh build reports 156 checker cases (70 refused), identical.

Generated by Claude Code

Base automatically changed from claude/vm-uefi to main October 13, 2026 17:09
…m, --root-fs, --extra-disk)

The VM tier can now install centos7-lamp the way 7.0-7.2 media did
(--root-fs xfs-v4 --lvm: a 500 MB /boot and a VG 'centos' with swap and
a root that fills it) and give it an empty second disk for rebuild and
carry (--extra-disk 30). Install choices, not boxes: a chroot box has no
disks. Each layout is cached apart; extra disks get their own overlay
every hop; runs record the layout and resume only a run with the same.
The default layout keeps its cache key. Stacked on wend#71.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017K4daGyJmuJf8k4B9HJ7yw
Signed-off-by: Claude <[email protected]>
…ck, commit and roll back once (SPEC "Relocate")

The adapter's [relocate] table holds the steps (preflight, GRUB refresh, place, copy, fixup, flip) as harness
commands fixes can't reach; tools/vm.py relocate runs them on a fresh copy of a box and proves the one-shot trial,
a hard reset back to the old root, commit and a one-shot rollback. tools/test_relocate.py checks preflight's
refusals, the copy's fstab and kernel line, and the flip with the real grub-editenv.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017K4daGyJmuJf8k4B9HJ7yw
Signed-off-by: Claude <[email protected]>
@TusanHomichi
TusanHomichi force-pushed the claude/project-thread-btwg94 branch from 9d49758 to 974b243 Compare October 13, 2026 17:11

Copy link
Copy Markdown
Member Author

Claude review: signed off on 974b243

Re-checked head 974b243 after the rebase onto main's #71 merge (c3af630). Nothing was changed or pushed.

  • git ls-remote origin claude/project-thread-btwg94 returns exactly 974b243.
  • git diff 9d49758 974b243 is empty: both commits have tree ad6c160. 9d49758 is the head that was already signed off.
  • git range-diff a786be5..9d49758 c3af6305..974b243 shows all 9 commits as =.
  • Main's merge commit c3af630 has the same tree as vm: install EL7 boxes, choose the root filesystem, and boot guests on UEFI #71's head a786be5 (eda5939), and c3af630 is the parent of the PR's first commit. So the PR's diff against main is exactly the diff that was reviewed before.
  • python3 -B wend check at 974b243 reports 64 fixes, 4 routes, 9 boxes, 34 runs: ok, with 0 WRONG or MISSED.
  • WEND_EL7_BASH=/tmp/b42/bash-4.2/bash python3 -B tools/test_relocate.py passes, so do the bash 4.2 parse and run cases. python3 -B tools/test_check.py passes too: every case passes or is refused as expected, and it exits 0.
  • All 9 commits from c3af630 to 974b243 have a DCO Signed-off-by line.

Generated by Claude Code

@TusanHomichi TusanHomichi changed the title vm: XFS v4 on LVM with an empty extra disk, and relocate onto it (stacked on #71) vm: XFS v4 on LVM with an empty extra disk, and relocate onto it Oct 13, 2026
@TusanHomichi
TusanHomichi marked this pull request as ready for review October 13, 2026 17:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T17:34:40.099182Z 974b243 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 974b243e59

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread adapters/el.toml Resolved
Comment thread tools/vm.py Resolved
@TusanHomichi
TusanHomichi merged commit 40ae8fd into main Oct 13, 2026
9 checks passed
@TusanHomichi
TusanHomichi deleted the claude/project-thread-btwg94 branch October 13, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-claude-review Waiting on the Claude review layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants