Tags: howto
I have an old spinning disk in my workstation used for the occasional backups and this thing is noiser and vibrates worse than the PC itself.
Today I had enough and wanted to get rid of this annoyance. Solution? Put the HDD into low power mode!
# /sbin/hdparm -y /dev/disk/by-id/ata-WDC_WD1003FZEX-00MK2A0_WD-WCC3F3TPK1DD |
This only momentarily fixes the problem, we need to make sure the command is run also at boot and when resuming from sleep.
This can be achieved in various ways, but today we're going to employ systemd since we're modern like that.1. First, run hdparm at boot, we do this by creating a new systemd service file, on my Fedora I do something like the following.. Obviously replace with your own paths.
# cat << "EOF" > /usr/lib/systemd/system/hdd-lowpower.service [Unit] Description=Put HDD into low power mode [Service] Type=oneshot RemainAfterExit=yes ExecStart=/sbin/hdparm -y /dev/disk/by-id/ata-WDC_WD1003FZEX-00MK2A0_WD-WCC3F3TPK1DD [Install] WantedBy=basic.target EOF # systemctl enable hdd-lowpower |
2. Now let's sort out the same but when the PC wakes up from suspend to RAM (I think this also works when resuming from hybernation), we do this by employing the systemd-suspend.service (see man):
# cat << "EOF" > /usr/lib/systemd/system-sleep/hdd-lowpower.sh #!/bin/bash if [ "${1}" == "post" ]; then /sbin/hdparm -y /dev/disk/by-id/ata-WDC_WD1003FZEX-00MK2A0_WD-WCC3F3TPK1DD && logger -t hdd-lowpower "HDD is in low power mode" fi EOF # chmod +x /usr/lib/systemd/system-sleep/hdd-lowpower.sh |