diff options
-rwxr-xr-x | slogthedog.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/slogthedog.sh b/slogthedog.sh new file mode 100755 index 0000000..7e00a4b --- /dev/null +++ b/slogthedog.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# slogthedog.sh - Detect ZFS pools missing SLOGs and offer to add one. +# Because sometimes the sync log needs a good boy. + +clear +cat << "EOF" + __ + __ /o \_ +<___/---' +πΆ SLOG THE DOG v1.0 +------------------------------- + Fetching sync logs since 2025 +EOF + +echo "" +echo "π Scanning ZFS pools for missing SLOGs..." + +for pool in $(zpool list -H -o name); do + if ! zpool status "$pool" | grep -q 'logs'; then + echo "π Pool '$pool' has no SLOG." + echo -n "Do you want to add a SLOG device to this pool? [y/N]: " + read answer + if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then + echo "" + echo "πΎ Available GPT-capable drives:" + gpart show | grep "GPT" | awk '{print $1}' | sort -u + echo -n "π Enter device name to use (e.g. nvd0 or nvme0n1): " + read dev + echo "" + echo "π§Ό Prepping /dev/$dev..." + gpart destroy -F /dev/$dev >/dev/null 2>&1 + gpart create -s GPT /dev/$dev + gpart add -t freebsd-zfs -l slog_${pool} -s 16G /dev/$dev + echo "β Adding /dev/gpt/slog_${pool} as log device to $pool..." + zpool add "$pool" log /dev/gpt/slog_${pool} + echo "β
SLOG added to pool '$pool' using /dev/gpt/slog_${pool}" + echo "" + else + echo "β Skipping pool '$pool'" + fi + else + echo "β
Pool '$pool' already has a SLOG." + fi +done + +echo "" +echo "π Done. Slog the Dog is wagginβ his tail. All pools checked." |