Persistent HDD APM settings
An HDD can be configured to spin down after a certain time via the APM settings which can be managed by smartctl. For example
sudo smartctl --set=apm,63 /dev/sdb
sets the APM (Advanced Power Management) level of disk sdb to 63, a fairly aggressive power-saving level. Note that APM controls how aggressively the drive manages power, not a literal spin-down timer; an actual idle timeout is configured separately, for example via hdparm -S.
Unfortunately, those settings do not persist after a reboot. To achieve persistence on systems with systemd installed, the following sdb-apm.service service file can be created in /etc/systemd/system/
[Unit]
Description=/dev/sdb apm settings
[Service]
ExecStart=/usr/sbin/smartctl --set=apm,63 /dev/sdb
[Install]
WantedBy=multi-user.target
After enabling the service with
sudo systemctl enable sdb-apm.service
the settings should persist even after a system reboot.