Skip to content

Instantly share code, notes, and snippets.

@nicman23
Created December 8, 2023 16:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicman23/0c057583fcf66d7d21f8d4c4af5d38e0 to your computer and use it in GitHub Desktop.
Save nicman23/0c057583fcf66d7d21f8d4c4af5d38e0 to your computer and use it in GitHub Desktop.
zfs hdd spindown script
#!/bin/zsh
pool=zdata
devices=$(zpool status -P $pool | grep /dev/ | awk '{print $1}')
intervalinsec=120
while true; do
zpool iostat -HyL zdata $intervalinsec 1 |
grep -q '0 0 0 0' ; res=$?
if [ $res -eq 0 ]; then
for i in `echo $devices`; do
hdparm -Y $i
done
while ( smartctl -i -n standby ${devices[0]} | grep -q 'Device is in STANDBY' ); sleep 1m
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment