From 4e2c6c9caff8cf6a535d8abe838c67cc9be013ad Mon Sep 17 00:00:00 2001 From: claude-hdb Date: Tue, 14 Jul 2026 00:03:21 +0000 Subject: [PATCH] fix: the clone identity reset could never reboot, so it never took effect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reset truncated /etc/machine-id and called 'incus restart'. But systemd needs a VALID machine-id to shut down cleanly — so the graceful stop hung, incus timed out ("Failed shutting down instance, status is Running: context deadline exceeded"), and the reboot never happened. The clone kept its source's machine-id, hence its DUID, hence its DHCP lease: two boxes on one address, which is the exact bug the reset exists to prevent. Worse, the duplicate address then broke the box's networking outright ("box cannot reach the internet"), and poisoned the isolation run downstream. Write a fresh VALID id with systemd-machine-id-setup instead of emptying the file — in a VM it derives from the DMI product UUID, which Incus makes unique per instance. Then restart with a real timeout and a forced fallback: a clone that keeps its source's lease is worse than an unclean stop of a box that booted thirty seconds ago. Co-Authored-By: Claude Fable 5 --- bin/claudebox | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/claudebox b/bin/claudebox index b91e556..96a3771 100755 --- a/bin/claudebox +++ b/bin/claudebox @@ -417,12 +417,21 @@ wait_agent() { reset_identity() { local i="$1" echo "claudebox: giving the clone its own identity (machine-id, DHCP lease)..." + # Do NOT truncate machine-id and reboot: systemd needs a valid one to shut + # down cleanly, so the graceful stop hangs and the reboot never happens — + # leaving the clone on its source's identity, which is the bug we are here to + # fix. 'systemd-machine-id-setup' writes a fresh VALID id instead; in a VM it + # derives from the DMI product UUID, which Incus makes unique per instance. incus exec "$i" -- sh -c ' - : >/etc/machine-id - rm -f /var/lib/dbus/machine-id + rm -f /etc/machine-id /var/lib/dbus/machine-id + systemd-machine-id-setup >/dev/null 2>&1 || dbus-uuidgen > /etc/machine-id ln -sf /etc/machine-id /var/lib/dbus/machine-id + test -s /etc/machine-id ' || die "could not reset the clone's machine-id" - incus restart "$i" + # The new id only takes effect at boot. Ask nicely, then insist — a clone that + # keeps its source's DHCP lease is worse than an unclean stop of a box that + # booted 30 seconds ago. + incus restart --timeout 60 "$i" >/dev/null 2>&1 || incus restart -f "$i" wait_agent "$i" }