Linux OSBN/Ubuntuusers Planet XING / LinkedIn / Amazon

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:

# vi /usr/lib/systemd/system/sda-spindown.service
[Unit]
Description=Set HDD spindown

[Service]
Type=oneshot
ExecStart=/sbin/hdparm -B 241 /dev/sdb
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

ESC ZZ
# systemctl daemon-reload
# systemctl enable sda-spindown.service
# systemctl start sda-spindown.service

You can verify that the value has been set successfully using the service management:

# systemctl status sda-spindown.service
sda-spindown.service - Fix excessive HDD parking frequency
   Loaded: loaded (/usr/lib/systemd/system/sdd-spindown.service; enabled)
   Active: active (exited) since Sa 2014-10-11 14:27:16 CEST; 3min 32s ago
   Process: 4336 ExecStart=/sbin/hdparm -B 241 /dev/sda (code=exited, status=0/SUCCESS)
...

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!]

🙂

Sharing is caring

Leave a Reply

Your email address will not be published. Required fields are marked *