#!/bin/zsh
# root-fs stop — final sync before halt/poweroff/reboot## Originally this script set the ZFS root dataset readonly=on as a# defensive "clean state for next boot" measure. That was actively# wrong: it made / read-only BEFORE zyginit's outer shutdown sequence# finished (destroy_socket's unlink of /var/run/zyginit.sock, the# explicit zpool sync + umountall, etc.). Every subsequent write# failed silently, so the next boot saw stale state — most visibly# the un-removed /var/run/zyginit.sock that wedged zygctl post-reboot.## ZFS is transactionally consistent — it doesn't need a "freeze"# before shutdown. zyginit's main shutdown sequence (`zpool sync`,# umountall -l, sync) plus the kernel's own vfs_syncall inside# uadmin's mdboot path is enough to guarantee txg commit before the# hardware reset.## UFS root would still need remount,ro for clean fsck. Hammerhead's# BE is ZFS, so this script is effectively a no-op (just a final# `zpool sync` as defense in depth). Add UFS handling here if/when# UFS root is supported.set -u
# Defense-in-depth: final zpool sync. zyginit's outer shutdown also# calls `zpool sync` post-shutdown_services; this covers the brief# window between filesystem/stop.sh's `umountall -l` and that call./usr/sbin/zpool sync 2>/dev/null || true
exit 0