HDD Sleep/Spindown/Standby

…noting, of course that once or twice a day, which is what interested users want to achieve here, is NOT “very often”.

Yep, agreed.

In the request, someone actually made a calculation showing that spinning the drives up once every hour (24 times a day) was still within specification for many years :slight_smile:

I want to point out that I am on the latest stable TrueNAS OS, and I find each morning my server running quite. I have set up spin down after 60min, and it is the only moment where I can find it spinning down.

I cannot say when it starts, and how long it last.

The disks a read or written each day at 00h for snapshot, at 2 in the morning, I have all the aar apps checking and jellyfin as well, and otherwise, I have Nextcloud connect to the drives via SMB.

So there no frequent access during the day, and the very frequent access are made on dedicated SSDs (for apps and containers).

The disks are used for main storage, but for personal use only, so not very frequent.

>someone actually made a calculation showing that spinning the drives up once every hour (24 times a day) was still within specification for many years :slight_smile:

That was me I think. It’s not that many years, only 410 (for 150k load cycles). So if you put your HDDs in a generation ship and send them on a 20,000 year journey to another star, they’re not going to last that long if you spin them down every day.

While I don’t dispute your logic, Load Cycle Count != Spin Up/down. Those are different actions and stats which often can correlate but don’t have to.

First of all thank you very much for you great patch, i’ve used several times with succes.

I’ve just updated to 25.10.3 and when i’ve tried to run the patch i get this:

Hmm…Ignoring potentially dangerous file name /usr/lib/python3/dist-packages/middlewared/plugins/pool_/dataset_encryption_info.py
Looks like a unified diff to me…
can’t find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:

|— /usr/lib/python3/dist-packages/middlewared/plugins/pool_/dataset_encryption_info.py        2025-11-23 16:29:54.794377157 -0800

+++ /usr/lib/python3/dist-packages/middlewared/plugins/pool_/dataset_encryption_info.py        2025-11-23 16:30:39.314554054 -0800

File to patch:

I’m not sure why and what’s happening but i don’t remember doing that for the previous updates.

If i just press enter i get :

Skip this patch? [y]

Would you be so helful to at least tell me if this might be because of the new version or i’m doing something wrong?

Thank you again.

I haven’t gotten around to trying this fix yet, so I can’t say; I’m still on 25.10.1. All of this is very problematic because there’s a multitude of things I have to fix in truenas before it becomes usable, and through every update the patches are prone to breaking. I’ve managed to lower the grub boot delay time and installed the correct realtek 2.5GBe driver for my system (truenas is handing out the wrong driver), and now hard drive spin-down is effectively broken and unusable. Other useful features have been removed too, such as the recycle bin and SMART system.

We really need a truenas fork don’t we? Perhaps a “configware” that modifies the database configuration prior to the middleware. I guess the only way of updating safely moving forward will have to be running another truenas separately and testing to see if all of the changes even work at all in newer versions or if I’ll just reach a point where it becomes impossible to update. It’s a shame I must say, considering ix does so many things right, but then makes it virtually impossible to use even the most basic features one would expect from a NAS system simply because it doesn’t fit their vision. Hopefully we’ll see a NAS system in the future that stays more true to the requirements of NAS systems.

Hi, did you do “cd /” before trying to apply the patch?
You must be on “/” directory for it to work.

cd /
sudo /usr/local/libexec/disable-rootfs-protection
sudo patch --verbose -N -p0 -i /path_to_file/spindown.patch

I’m ashamed to say that it was exaclty my issue.

Thank you very much.

Been running the patch on truenas 25.10.1 now for a bit and it seems to work great. The only issue I have is occasional wattage spikes during spin-down and when spun-up (35w idle → 50w). I suspect this is related to my truenas boot NVME which uses APST (PCIe link still in ASPM). It’s probably waking up the PCIe hierarchy occasionally. At the same time I don’t know if this specific truenas version introduced any other kinds of background activity that could be causing this.

Thanks for this.

It seems it’s gonna be needed in future releases as well. Do you mind to put it on github? This way we can track compatibility and put needed changes there. We can also wrap it with single paste one-liner.

@AndBu’s idea inspired me to make thre spindown.patch simple with the below script…

Using this patch method means never disturbing the actual TrueNAS system files.

spindown-fix.sh will automatically copy, patch and then individually bind-mount the all the required patched system files (see below) over the top of their original system paths.

https://github.com/itiligent/TrueNas-Tricks/blob/main/spindown-fix.sh

Instructions are in the script. It can be run multiple times to:

  1. Create the system file copies in user selected overlay location
  2. Dry run the patch (to test first)
  3. Apply the patch to the copied files and mount these as overlays
  4. Supply the specific preinit bind mount commands for remounting the overlays after reboot.
  5. Check on the existence of patched files, status of overlay mounts, unmount etc

The files copied, patched and mounted as overalys by this script are are:

/usr/lib/python3/dist-packages/middlewared/plugins/pool_/dataset_encryption_info.py
/usr/lib/python3/dist-packages/middlewared/utils/disks_/disk_class.py
/usr/lib/python3/dist-packages/middlewared/alert/source/smart.py
/usr/lib/python3/dist-packages/middlewared/plugins/disk.py

An extra bonus of this method is safely and ease of updating. You can easily return TrueNas to its original state by disabling the preinit boot commands. You can the re-enable these to re-apply the patched overlay after upgrades.

Following on from my previous post sharing spindown-fix.sh helper script, I’ve written a companion script to help diagnose the specific processesthat are waking your HDDs in your ZFS pools.

This companion hdd-wake-trace.sh script monitors the power state of rotational disks in a selected pool.

When one or more disks transition from standby to active/idle, it captures an event log containing disk state, ZFS pool status, zpool, iostat, process I/O deltas, recently started processes, relevant system timers, open files within mounted datasets and can also time correlate the journal activity before and after the HDD wake event for a configurable time line.

The script can also be run with specific built-in configuration profiles to collect basic , balanced and heavy levels of log data too.

I can’t share links for this forum as yet:

https://github.com/itiligent/TrueNas-Tricks/blob/main/hdd-wake-trace.sh

Have you taken the tutorial by the forum bot?

you can message @TrueNAS-Bot and start the tutorial.
We had issues with spamm bot attacks in the past, hence the hurdle to post links

Hi! To find out what I can do, say @truenas-bot display help.

thanks lars, but my profile has no option to directly message anyone, including @truenas-bot. Thanks for your help, but I don’t time to chase this.

top right corner next to your profile icon is a chat bubble icon where you can open direct messages with each forum user, including the truenas bot

I tried it, I can’t send any messages.

Edit: But clicking on the bot in this thread and starting a chat there works!

you can also click on the Truenas-bot name a few posts up which should open a popup window with an option to message and chat the bot