Persistent HDD APM settings

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

configures the disk sdb to spin down afout about 5 minutes of inactivity.

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.