Do these settings vanish after each reboot?
In case of a soft reboot, where the drive stays powered up, the settings don't vanish. Power cycle does reset the APM parameter. (At least, on my laptop)
Most setters are also getter options in
hdparm. The APM setting can be easily checked by:
# hdparm -B /dev/sdb
APM_level = 128
This doesn't work for the stand-by timer option, though. But logically, those settings are lost also.
Where should I put those commands in order for it to be persistent?
All kind of options, custom
cron job (
@reboot). What suits you the best.
Arch wiki is quite a nice resource for more info.
Inspired by the above wiki, I created a
systemd service file for my Gentoo system:
ExecStart=/sbin/hdparm -S 12 -B 127 /dev/sdb
You may want to affect all of your devices with your settings at once as follows:
ExecStart=/sbin/hdparm -B 127 -S 241 /dev/sda /dev/sdb /dev/sdd /dev/sde
Note that you have to use absolute paths for everything, you can't do e.g.
cmd /dev/sd[abde]. The exact location to the
hdparm binary can be different in your distribution.
Use the following command to know location of your
hdparm which would normally be called:
Then, you may enable the service and optionally start it, you may simply want to reboot the machine to be 100% sure it works.
# systemctl enable hdparm.service
# systemctl start hdparm.service
# systemctl status hdparm.service
Arch's proposal suppresses output, but I prefer to verify the success of
hdparm with the last issued command.
I found that after suspend, the parameters where not hold by my hard drive. This might be the case for more laptop systems. Therefore I've modified the example unit file. Courtesy to this answer on unix.SO.