Short tip: configure hard drive standby with systemd
Hard drives can be forced into hibernate using hdparm
. While it was quite easy to implement automatic setting this hibernation values by inserting the appropriate command (hdparm -B intervall device
) into /etc/rc.local
(which was executed after the boot) on sysvinit
-based Linux distributions this changed on newer systemd-based systems. It is a good idea to implement this behavior as a service.
First you need to create a system-wide service and activate and start it afterwards:
1# vi /usr/lib/systemd/system/sda-spindown.service
2[Unit]
3Description=Set HDD spindown
4
5[Service]
6Type=oneshot
7ExecStart=/sbin/hdparm -B 241 /dev/sdb
8RemainAfterExit=yes
9
10[Install]
11WantedBy=multi-user.target
12
13ESC ZZ
14# systemctl daemon-reload
15# systemctl enable sda-spindown.service
16# systemctl start sda-spindown.service
You can verify that the value has been set successfully using the service management:
1# systemctl status sda-spindown.service
2sda-spindown.service - Fix excessive HDD parking frequency
3 Loaded: loaded (/usr/lib/systemd/system/sdd-spindown.service; enabled)
4 Active: active (exited) since Sa 2014-10-11 14:27:16 CEST; 3min 32s ago
5 Process: 4336 ExecStart=/sbin/hdparm -B 241 /dev/sda (code=exited, status=0/SUCCESS)
6...
Many thanks to the following blog that gave me the tip: [click me!]
Another (probably nicer) solution is to create a udev
rule: [click me!]
🙂