Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10 Minute housekeeping_timeout keeps Western Digital Drives awake. #892

Open
reidjr opened this issue May 28, 2021 · 17 comments
Open

10 Minute housekeeping_timeout keeps Western Digital Drives awake. #892

reidjr opened this issue May 28, 2021 · 17 comments

Comments

@reidjr
Copy link

reidjr commented May 28, 2021

Western Digital Hard drives have a minimum 10 min sleep idle timer.
If they are polled for SMART status, they will reset that timer, and wait another 10 mins before spinning down.

Where udisks2 is used, the default housekeeping timer of 10 mins means that the drive never sleeps, as the timer is always reset.

If the drive is spun down manually, then it is not woken by polling.

I have 3 different western digital hard drive models , all exhibit this behaviour.

Simply changing the housekeeping timer to 15 mins stops this issue. With this small change the WD drives spindown when Idle and stay down.

udisks2-2.8.4/src/udiskslinuxprovider.c udisks2-2.8.4.new/src/udiskslinuxprovider.c
691,692c691,692
<   /* schedule housekeeping for every 10 minutes */
<   provider->housekeeping_timeout = g_timeout_add_seconds `(10*60,`
---
>   /* schedule housekeeping for every 15 minutes */
>   provider->housekeeping_timeout = g_timeout_add_seconds (15*60,
1479c1479
< /* called from the main thread on start-up and every 10 minutes or so */
---
> /* called from the main thread on start-up and every 15 minutes or so *
@stheid
Copy link

stheid commented Jan 5, 2022

image
image

on my NAS it even wakes up my sleeping drive (hdparm -Y /dev/sda) as very evident in the power consumption and the dmesg logs

The problem is also described here 1 but the solution does not work on my machine.

systemctl stop udisks2 "solves" the issue, therefore i am sure it is udisks related

@stheid
Copy link

stheid commented Jan 5, 2022

Even though it is somewhat an issue of udisks it seems to be caused by using setting powercontrol of the device to "auto" of the device. When i re-enable power control for the device in question stays spinned down and even the dmesg mesages disappear.

Therefore my workarround is

  powertop --auto-tune
  echo 'on' > '/sys/block/sda/device/power/control'

and the device stays quiet (with udisks2.service being active):
image

That being said, i would still argue, that the issue is not solved, because udisks should in no case cause a disk to spin up just to read smart data or whatever.

@bughunter2
Copy link

I can confirm this problem, even with disks from other brands such as Toshiba.

As mentioned by @stheid, I agree that udisks should NOT wake up disks to do 'housekeeping' every few minutes.

@reidjr
Copy link
Author

reidjr commented Feb 26, 2022

Is there a reason why setting the housekeeping timers to 15 mins isn't the right answer ? or making it user configurable ?
It is a problem that cannot be worked around because its disk firmware dependent ( I assume).

Or do all the Devs not spin down their drives or use another brand :-) :-) :-)

@bughunter2
Copy link

bughunter2 commented Feb 27, 2022

There seem to be at least 2 cases where udisks can wake up disks or keep them awake.

For one, drives that are in sleep/standby mode seem to be woken up just to read smart data or such. That should not happen, I hope everyone agrees on that. So, changing that behavior would at least be a partial fix.

If you put a drive in sleep mode via hdparm -Y /dev/sdxxx and wait ~10 minutes, you can observe that udisks is waking up the disk. This can be observed by tracing the I/O:
$ sudo blktrace -d /dev/sdxxx -a pc -o - | blkparse -i -

Aside from that, making the housekeeping timer configurable may also be helpful, as mentioned by @reidjr
Also, I think udisks should strive to have defaults that at least work for, say, 80% to 99% of the users.
Thus, increasing the default housekeeping timeout to 15 or 30 minutes may help reduce the number of users that experience this problem.

To sum the proposed ideas from this thread up:

  • udisks shouldn't wake up disks that are in sleep/standby just to read smart data or such
  • increase the default housekeeping timeout to 15 or 30 minutes
  • and/or make the housekeeping timeout configurable

Together, such changes could at least partially solve the problem and give users control to at least solve it for themselves.

@jeffr1975
Copy link

I am also impacted by this issue. Stopping udisks2 stops the 4 western digital drives from spinning up. That is the only workaround I have found. I am running Ubuntu 21.10. I can't seem to get any of the suggested workarounds to stop this behavior.

@reidjr
Copy link
Author

reidjr commented Mar 31, 2022

just patching this again for Ubuntu 22.04 :-( same hack fixes it.

@MrDach
Copy link

MrDach commented Sep 9, 2022

I am also experiencing this issue on Ubuntu 22.04 LTS server.
I found a comment suggesting that disabling "Smart function" in some Gnome disks GUI should stop the polling through udisks, but since I'm running a headless version on my NAS I'm not really sure how to do so.
Has anyone come up with a good way to solve this issue?

@reidjr
Copy link
Author

reidjr commented Sep 9, 2022

Patch and recompile the source as per my first post is the fix without changing anything else, or turning off functionality.

Bit of googling will show this is not the first time this has come up, looks like it will never be picked up or fixed by the devs.
#407 etc

Turning off udisk SMART should be (?) possible through /etc/udisks2/[diskidentifier].conf but you will need to search for the format, as I didnt try this myself.

@MrDach
Copy link

MrDach commented Sep 9, 2022

Guess I'll have to look into how you compile in Linux 😅 Always something new to learn..

@chwiede
Copy link

chwiede commented Nov 6, 2022

I'm affected by the same problem. Honestly, to patch the source after every upgrade can't be the solution.
This hard coded 10-minute value should be configurable. Come on udisks devs, let's save some energy!

@raspberryfan
Copy link

raspberryfan commented Nov 16, 2022

I was facing the same issue with Kubuntu 22.04 LTS with udisks2, smartd and an external USB3 Seagate HDD. After trying lots of tweaks I found on the internet - without success - I came to the following solution (the drive in question is constantly connected to the host - I assume most drives affected are, only then one would want to make them go into standby):
I have disabled smartd and now mount the USB drive in fstab instead of letting udisks2 do the job and set the spindown time in /etc/hdparm.conf. That way udisks2 is not involved thus does not do householding and also smartd does not bother the drive. I have not tested if I might re-enable smartd now using fstab because I am fine with the current configuration. I do check the smart status every now and then when upgrading the system.
Disable smartd:
~$ sudo systemctl disable smartd
Since device names can easily change with external drives it makes sense to use the UUID at least for the affected drive(s) in fstab and the /dev/disk/by-id in hdparm.conf.
Find the current device name and the UUID for the HDD:

~$ lsblk -f
NAME  FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
[...]
sdc
└─sdc1
      ext4   1.0   Backup
                         cd9939ee-65dc-4567-8efe-0c146dfe8a6b    1,7T    46% /mnt/backup
[...]

Find the related /dev/disk/by-id:

~$ udevadm info --query=all --name=sdc
[...]
S: disk/by-id/wwn-0x5000c500e4f3f868
[...]

My fstab:

~$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
UUID=aefa4062-0355-481a-90b2-b0e50d478b9c /                   ext4    errors=remount-ro         0       1
[...]
UUID=cd9939ee-65dc-4567-8efe-0c146dfe8a6b /mnt/backup         ext4    defaults,nofail,discard   0       0

My hdparm.conf

~$ cat /etc/hdparm.conf
# 72 = 6 minutes, two partitions are incrementally backed up to the drive, time between backups is 5 minutes,
# drive is spinning for about 10 minutes per day 
[...]
/dev/disk/by-id/wwn-0x5000c500e4f3f868 {
spindown_time = 72
}

If you want to go this way please make sure you adapt the device values when editing /etc/fstab and /etc/hdparm.conf according to your drive(s).

@kub3let
Copy link

kub3let commented Jan 16, 2023

Wasted 3 hours today figuring out what kept my drives from spinning down.

Really weird since I only installed udisks2 to setup the spin down.

Switching to hdparm fixed it.

@tbzatek tbzatek added this to the udisks-2.11.0 milestone Apr 5, 2023
@CalebCZ
Copy link

CalebCZ commented Mar 30, 2024

Hi guys, any news? I have same issue with Seagate Ironwolf 4TB NAS drive.
Would it be possible to provide a patch (with timeout set to at least to 1 hour) until the release 2.11 is done, please?

@lilydjwg
Copy link

I have a patch to completely disable it:
dont-spin-up.txt

@MarkusEh
Copy link

I uninstalled udisks on my server.

  • Solves this issue :) .
  • Also solves issues with USB drives resetting when you send ATA commands (OK, this is a bug. But: without udisks, I can ignore the bug ...)

@soxhi8
Copy link

soxhi8 commented Jul 18, 2024

Found this to be the cause for my issues with getting disks (HGST-made) in a file-server to spin down. Setting the interval to 15 minutes would not be a fix for my use case, since the timeout is 2 hours for this application, to minimize on spin-ups/-downs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.