Update configuration.nix
This commit is contained in:
@@ -230,15 +230,21 @@
|
|||||||
ROOT_SRC="$($FINDMNT -n -o SOURCE / || true)"
|
ROOT_SRC="$($FINDMNT -n -o SOURCE / || true)"
|
||||||
[ -z "$ROOT_SRC" ] && exit 0
|
[ -z "$ROOT_SRC" ] && exit 0
|
||||||
|
|
||||||
DEV="$ROOT_SRC"
|
# Resolve to top-level disk exactly once
|
||||||
while PARENT="$($LSBLK -no PKNAME "$DEV" 2>/dev/null)"; [ -n "$PARENT" ]; do
|
PARENT="$($LSBLK -ndo PKNAME "$ROOT_SRC" 2>/dev/null || true)"
|
||||||
DEV="/dev/$PARENT"
|
if [ -n "$PARENT" ]; then
|
||||||
done
|
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
|
while [ -e "/sys/class/block/$DEV_NAME" ]; do
|
||||||
$SLEEP 0.5
|
$SLEEP 1
|
||||||
done
|
done
|
||||||
|
|
||||||
$SYSTEMCTL poweroff
|
$SYSTEMCTL poweroff
|
||||||
|
|||||||
Reference in New Issue
Block a user