Skip to content

Setting up HDD spindown using hdparm on a WD PR2100

Update: If your drive never spins down, use iosnoop to see if ext4lazyinit is constantly writing to the disk. This may take days or weeks to complete. If it is, follow this guide to unmount and remount your drive with the init_itable=0 option to force the process to complete. After that, your drive should spin down as expected!

If you're using your PR2100 as a backup device or data grave, you may want to spin down the HDDs when they're not in use to save energy and reduce noise.

Spinning down the HDDs (after a reasonable delay) might increase their lifespan but also increases the time it takes to access data on them. If you're using your PR2100 as a NAS, you may not want to do this.

Spoiler: Approach 4 is the only one that consistently and reliably worked for me.

Approach 1: udev rules

  1. ssh into your PR2100
  2. for each drive
    1. find out the short serial by running udevadm info /dev/sdX | grep SHORT, replace sdX with the device id of your drive, e.g. sda
    2. run sudo nano /etc/udev/rules.d/69-hdparm.rules and enter the following line
    ini
    ACTION=="add", SUBSYSTEM=="block", KERNEL=="sd[a-z]", ENV{ID_SERIAL_SHORT}=="SERIAL_FROM_ABOVE", RUN+="/usr/sbin/hdparm -B 127 -S 241 /dev/sdX"
    replace SERIAL_FROM_ABOVE with the short serial you acquired in step 2.1 and sdX with the device id of your drive, e.g. sda
  3. reboot your PR2100 (hard)
  4. run sudo systemctl status udev.service and look for any errors related to your drives

Never worked for me

Approach 2: cron

  1. ssh into your PR2100
  2. run sudo crontab -e
  3. for each drive
    1. enter a new line at the bottom of the file
    @reboot sleep 30 && /usr/sbin/hdparm -B 127 -S 241 /dev/sdX
    replace sdX with the device id of your drive, e.g. sda
  4. reboot your PR2100 (hard)

The -B parameter must be set below 128, because values above 127 apparently disable spindown.

Worked for me initially while testing with an old samsung drive, but not with my new WD Red drives

Approach 3: hdparm.conf

See this post for a configuration example AND several hacks that may or may not be required to make it work.

Never worked for me

Approach 4: hd-idle

Heads up: for reasons related to using usb boot media you must set the spindown time to less than 10 minutes. YMMV

Install using the instructions here.

Very easy to set up and the most straightforward solution I've found so far.

I'm using the following configuration in /etc/default/hd-idle:

ini
START_HD_IDLE=true
# documentation...
HD_IDLE_OPTS="-i 0 -a sda -i 450"

This disables spindown by default (my M.2 ssd wont need it) and sets the spindown time to 7:30 minutes for sda.

Append -a sdX -i NN for each additional drive you want to spin down.

Inspecting hd-idle's log

To see if your config is working as expected, set HD_IDLE_OPTS="-d -i 0 -a sda -i 60", then restart hd-idle by running sudo service hd-idle restart.

This will enable debug logging and set the spindown time to 60 seconds for easier inspection.

Next, make sure your drive is awake by writing to the disk touch /YOUR/MOUNT/FOLDER/wakeup, then wait for it to spin down again.

Now, run watch -c "sudo SYSTEMD_COLORS=1 systemctl status hd-idle" and keep watching the log for a minute.

sdas reads and writes values should not change and the idleDuration should increase every time the log is updated.

When the idleDuration reaches 60 seconds, a line reading sda spindown should appear in the log.

Congratulations, your drive is now spinning down after 60 seconds of inactivity.

Revert the changes to HD_IDLE_OPTS and restart hd-idle again to go back to your normal configuration.

This is what I'm using now and I am very happy with it 👍

Approach 5: udisks2

The documentation suggests that you can control the spindown using udisks and that it will remedy the issue where the udisks "housekeeping" process wakes up the drives every 10 minutes but it didn't work for me.

Never worked for me

Check if it works

After the drives should have spun down, you can check if they're still active by running one of the following commands:

Using hdparm

run sudo hdparm -C /dev/sda and look for drive state is: standby in the output.

/dev/sda:
 drive state is:  standby

Using smartctl

sudo apt install smartmontools -y (reason) then sudo smartctl -i -n standby /dev/sda.

The output should look like this:

  smartctl 7.2 2020-12-30 r5155 [x86_64-linux-5.15.0-91-generic] (local build)
  Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org

  Device is in STANDBY mode, exit(2)

hdparm Spindown Time Notation

From the documentation:

The value of 0 disables spindown, the values from 1 to 240 specify multiples of 5 seconds and values from 241 to 251 specify multiples of 30 minutes.

Here's a table with some examples:

ValueTime
0disabled
15 seconds
210 seconds
12010 minutes
24020 minutes
24130 minutes
24260 minutes
24390 minutes
244120 minutes
250240 minutes

Clicking this button loads third-party content from utteranc.es and github.com