diff --git a/020_zfs-apt-snapshot.sh b/020_zfs-apt-snapshot.sh index f6429e7..864d03d 100644 --- a/020_zfs-apt-snapshot.sh +++ b/020_zfs-apt-snapshot.sh @@ -1,6 +1,13 @@ #!/usr/bin/env bash -POOL_NAME=rpool +ROOT_DATASET=$(zfs list -H -o name,mountpoint | awk '$2 == "/" { print $1 }') +if [ -z "$ROOT_DATASET" ]; then + echo "Error: Could not detect ZFS dataset mounted at /" >&2 + exit 1 +fi + +# Usually the pool name is the first component (rpool/ROOT/ubuntu → rpool) +POOL_NAME="${ROOT_DATASET%%/*}" # Create zfs snapshots before apt operations using apt hooks @@ -9,8 +16,8 @@ POOL_NAME=rpool conf_print_snapPrepApt() { cat <