blob: 7e00a4bb1ce91cc18731114612dc323451b96a98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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."
|