lynix / hdd-spindown.sh

Automatic Disk Standby using Kernel diskstats and hdparm
MIT License
52 stars 16 forks source link

hdd-spindown.sh doesn't work anymore #1

Closed nick-s-b closed 7 years ago

nick-s-b commented 7 years ago

Hi! I've been using hdd-spindown.sh for quite some time now and never had any issues. However, after the recent update, hdd-spindown.sh never puts my HDD to sleep anymore. I've updated the package from AUR last night and noticed issues today.

First issue I've noticed after the update was that the service was disabled. After enabling and starting the service manually, service reports that it's up and running:

$ systemctl status hdd-spindown.service
● hdd-spindown.service - Automatic Disk Standby
   Loaded: loaded (/usr/lib/systemd/system/hdd-spindown.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2017-07-12 21:31:52 EDT; 40min ago
 Main PID: 515 (hdd-spindown.sh)
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/hdd-spindown.service
           ├─ 515 /bin/bash /usr/bin/hdd-spindown.sh
           └─7931 sleep 300

Jul 12 21:31:52 exp1 systemd[1]: Started Automatic Disk Standby.
Jul 12 21:31:52 exp1 hdd-spindown.sh[515]: Using 300s interval

But my disk is never put to sleep. If I issue an hdparm request manually, the HDD does spin down (I can hear it spin down).

And then, sometimes later I see this in my journal:

Jul 12 22:21:59 exp1 hdd-spindown.sh[515]: spinning up sdb

so it's spinning up the disk on its own at who knows what interval. Really strange.

My rc file is simple:

$  cat  /etc/hdd-spindown.rc
CONF_INT=300
CONF_DEV=("sdb|300")

What is going on? Thanks in advance!

PS: Using Arch, latest version from AUR.

lynix commented 7 years ago

Thanks for using hdd-spindown.sh :)

I think I've found the cause for your issue: as you're not using the presence feature, the default presence initialization is never updated. This was wrong since ae003ab (defaulting to always-present), resulting in disks never put to sleep.

I'll bump the AUR package in a few moments, please try with the new version and let me know if this fixes your issues.

lynix commented 7 years ago

Almost forgot to comment on your second issue:

First issue I've noticed after the update was that the service was disabled.

The systemd unit name changed with 28f44f143, it's now called hdd-spindown.service instead of hdd-spindown.sh.service. So you needed to re-enable it as it's a different unit for systemd now.

nick-s-b commented 7 years ago

Hi @lynix Thank you so much for replying! I've upgraded the package from AUR but it still doesn't put the HDD to sleep. For example, here's the status:

$ sudo systemctl status hdd-spindown.service
● hdd-spindown.service - Automatic Disk Standby
   Loaded: loaded (/usr/lib/systemd/system/hdd-spindown.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2017-07-13 20:48:16 EDT; 13min ago
 Main PID: 519 (hdd-spindown.sh)
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/hdd-spindown.service
           ├─ 519 /bin/bash /usr/bin/hdd-spindown.sh
           └─3701 sleep 300

Jul 13 20:48:16 exp1 systemd[1]: Started Automatic Disk Standby.
Jul 13 20:48:16 exp1 hdd-spindown.sh[519]: Using 300s interval

After I upgraded, I made sure the service was enabled and running and then rebooted. After starting up, I did not touch my HDD (sdb) and just left the computer on. 13 min after, the sdb HDD is still up even though I've set it in .rc to spin down after 300sec/5min.

I then manually tried putting it to sleep:

Jul 13 21:02:10 exp1 sudo[3975]:      nsb : TTY=pts/0 ; PWD=/home/ext ; USER=root ; COMMAND=/usr/bin/hdparm -y /dev/sdb

It worked and this time the hdd-spindown service didn't wake it from sleep like it did before. So that part now works fine. But for some reason, it won't put the disk to sleep.

Any ideas? Anything I could try? Thanks so much!

nick-s-b commented 7 years ago

Finally, it works again. I restarted the computer without the .rc file, then I stopped the service, wrote a new file and changed the time and started the service. Now everything works. Thanks again @lynix for such a wonderful script!