From 6ca4256b3e724155b9aea87b5f8c747784acc56e Mon Sep 17 00:00:00 2001 From: cyteen Date: Wed, 11 Mar 2026 02:15:45 +0000 Subject: [PATCH] Adds apt hooks to create a snapshot before operations. --- 020_zfs-apt-snapshot.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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 <