Skip to content

Instantly share code, notes, and snippets.

@AaronBeier
Created March 10, 2025 22:29
Show Gist options
  • Select an option

  • Save AaronBeier/48146eef7b3eb5651b500fcc77ba6bf9 to your computer and use it in GitHub Desktop.

Select an option

Save AaronBeier/48146eef7b3eb5651b500fcc77ba6bf9 to your computer and use it in GitHub Desktop.
Simple bash script to allow all HDDs to spin down
#!/bin/bash
# See https://wiki.archlinux.org/title/Hdparm#Power_management_configuration
# for -B and -S explanations and values
for disk in /sys/block/sd*; do
disk_name=$(basename "$disk")
rotational=$(cat "/sys/block/$disk_name/queue/rotational")
if [ "$rotational" -eq 0 ]; then
continue
fi
hdparm -B 127 /dev/$disk_name > /dev/null 2>&1
hdparm -S 120 /dev/$disk_name > /dev/null 2>&1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment