Skip to content

persistent logs + quieter init coordination#10

Merged
ananthb merged 1 commit into
mainfrom
feat/persist-logs-and-quiet-pivot
Jul 12, 2026
Merged

persistent logs + quieter init coordination#10
ananthb merged 1 commit into
mainfrom
feat/persist-logs-and-quiet-pivot

Conversation

@ananthb

@ananthb ananthb commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

Two changes bundled — both improve the pivot's post-mortem UX.

Persistent logs

--log-persist-path (default /var/log/xmorph) writes xmorph's own log and the entrypoint's stdout+stderr to a directory on the old rootfs (default). Optional --log-persist-device picks a specific pre-pivot mount to host it. Because the directory survives the kernel restart triggered by RebootOnFailure, you can tail it on the recovered OS to see why the pivoted install died — no more "box came back, no idea what happened."

  • Pre-pivot check confirms the resolved directory is writable (mkdir + probe file) and aborts if not.
  • Requires KeepOldRoot != \"\" (no persistent logs without an old root to persist to).
  • Empty --log-persist-path disables.
  • Slog is teed to <dir>/xmorph.log, the entrypoint's stdout+stderr to <dir>/entrypoint.log.

Quieter init coordination

initsys.Coordinator.TransitionToRescue now isolates basic.target instead of rescue.target on systemd hosts. rescue.target activates rescue.service which runs sulogin on the console — with a locked root, that looks like an emergency prompt during every pivot. basic.target stops all user services (same coverage) but keeps journal + dbus and doesn't touch tty state.

Test plan

  • go test ./internal/... on Linux (endeavour): all pass.
  • New TestSuperviseTeesToLogWriter confirms both stdout and stderr land in the writer.
  • configwrite_test extended for LogPersistDir round-trip and empty-omission.
  • Real hardware: pivot enterprise, deliberately fail install.sh, confirm the log appears on the recovered NixOS under /var/log/xmorph/.

--log-persist-path (+ --log-persist-device) writes xmorph's own log
and the entrypoint's stdout+stderr to a directory on the old rootfs
(default /var/log/xmorph). Because that directory survives the
kernel restart triggered by RebootOnFailure, you can `tail` it on
the recovered NixOS to see why the pivoted install died. Pre-pivot
check confirms the directory is writable and aborts otherwise.
Requires KeepOldRoot to be non-empty.

initsys.Coordinator.TransitionToRescue now isolates basic.target
instead of rescue.target on systemd hosts. rescue.target activates
rescue.service which runs sulogin on the console — with a locked
root, that looks like an emergency prompt during every pivot.
basic.target stops all user services (same coverage) but keeps
journal + dbus and doesn't touch tty state.
@ananthb
ananthb merged commit 97aee78 into main Jul 12, 2026
1 of 2 checks passed
@ananthb
ananthb deleted the feat/persist-logs-and-quiet-pivot branch July 12, 2026 22:18
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.

1 participant