diff --git a/configuration.nix b/configuration.nix index 1727523..c4dc575 100644 --- a/configuration.nix +++ b/configuration.nix @@ -230,15 +230,21 @@ ROOT_SRC="$($FINDMNT -n -o SOURCE / || true)" [ -z "$ROOT_SRC" ] && exit 0 - DEV="$ROOT_SRC" - while PARENT="$($LSBLK -no PKNAME "$DEV" 2>/dev/null)"; [ -n "$PARENT" ]; do - DEV="/dev/$PARENT" - done + # Resolve to top-level disk exactly once + PARENT="$($LSBLK -ndo PKNAME "$ROOT_SRC" 2>/dev/null || true)" + if [ -n "$PARENT" ]; then + ROOT_DEV="/dev/$PARENT" + else + ROOT_DEV="$ROOT_SRC" + fi - DEV_NAME="$($BASENAME "$DEV")" + DEV_NAME="$($BASENAME "$ROOT_DEV")" + + # Sanity check: ensure device exists before watching + [ ! -e "/sys/class/block/$DEV_NAME" ] && exit 0 while [ -e "/sys/class/block/$DEV_NAME" ]; do - $SLEEP 0.5 + $SLEEP 1 done $SYSTEMCTL poweroff