SOLVED How to configure TrueNAS Scale as home NAS with HDD spin down

chk

Cadet
Joined
Nov 25, 2016
Messages
3
Hi,
I am currently evaluating TrueNAS Scale 22.02-RC.2 to replace my old home NAS. My aim is to host PiHole, Unifi Controller and maybe some other containerized services and to have some TBs of storage shared via SMB / WebDAV.
As I barely use the storage - maybe 2-4 times a week for system backup for 2 PCs or when I have to store some scanned documents - I would like to spin down the HDDs when they are inactive to minimize noise, heat and energy consumption

I am using an Intel C3558 based board (A2SDi-4C-HLN4F) with an M.2 SSD for the system and two 3,5" HDDs for the storage. I installed TrueNAS Scale on the SSD and created a pool on the two HDDs, but did not installed anything else or setup sharing yet.

I tried to set the timeout to 5 min and the power managegment to 1, however the two HDDs are never going to spin down. For testing I deleted the pool on those HDDs and now they are spin down. So it seems possible that TrueNAS Scale is able to spin down the HDDs.

Is spin down not supported when having a ZFS pool on the disks? Or is something else using the pool I am not aware of? How would you configure a TrueNAS Scale system with a big, but low-accesed storage pool that minimizes noise, heat and energy consumption?

Any hints / recommendations are highly appreciated. Thank you.
 

chk

Cadet
Joined
Nov 25, 2016
Messages
3
I would assume that PiHole and Unifi have some occasional pool access?

For TrueNAS CORE, there is a special script to spin down the drives. This would work for the occasional SMB access.

https://www.truenas.com/community/resources/hdd-spindown-timer.122/

I'm not sure if anyone is attempting to port this to SCALE. Please let us know if you are.
Thanks for your reply.
I do not have PiHole and Unifi running at the moment. I just installed TrueNAS Scale, changed the timeout / power management settings for the disks and created a pool.
 

aloisdecroon

Cadet
Joined
Feb 27, 2022
Messages
2
Thanks for your reply.
I do not have PiHole and Unifi running at the moment. I just installed TrueNAS Scale, changed the timeout / power management settings for the disks and created a pool.

Did you find a solution chk ?

I'm bumping this topic because its exactly my question, like to spindown 4x SAS drives on my truenas scale install which used very often.
 

chk

Cadet
Joined
Nov 25, 2016
Messages
3
Did you find a solution chk ?

I'm bumping this topic because its exactly my question, like to spindown 4x SAS drives on my truenas scale install which used very often.
no unfortunately I did not find a solution...
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I see this resource was already found (and as I understand it is the only/best way to have both smartctl and spinning down in any reliable way):

It seems to me that somebody with a little time and understanding of debian and bash would be able to find the right lines in the spindown script to change to make them compatible with SCALE... (https://github.com/ngandrass/freenas-spindown-timer/blob/master/spindown_timer.sh)

All that's really needed is a change to the regex to find the drive names from iostat output and then to find the equivalent commands for camcontrol to actually spin the drives down (a quick google showed me maybe hdparm might be it).


So line 126 needs to go from something like this:
`iostat -x | grep -E '^(ada|da)' | awk '{printf $1 " "}'` (for CORE)

to

`iostat -x | grep -E '^(sd)' | awk '{printf $1 " "}'` (for SCALE)

and then for the lines with camcontrol... 217, 223, 238, 241, 132

seems hdparm -Y /dev/sdx puts a drive to sleep

hdparm -y /dev/sdx puts a drive to standby

hdparm -C /dev/sdx Checks on the drive status (sleep/standby/active) ... and importantly doesn't impact that status

hdparm -I /dev/sdx Shows a lot of information about the drive ... but will wake it from sleep or standby.

That's almost all the work done... anyone want to take the glory for putting it all together?
 
Last edited:

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Seems no takers... I had a shot at it... I couldn't confirm if it's working or not, but it does run...


A side-note here...

I didn't really want to get involved with this as I don't personally agree with spinning drives down, but I do see a large number of folk out there with extreme concerns over power consumption, so I figure they will try (and possibly fail) to find ways to do it... better to help the overall experience and give advice along the way.

Know that you're burning out your disks earlier than necessary by using a script like this.
 

ChrisRJ

Wizard
Joined
Oct 23, 2020
Messages
1,919
To me it looks like running Pi-Hole and the Unifi Controller off of a Raspberry Pi might actually be an alternative. If you only the NAS a few times a week, I personally would not want the hazzle with fine-tuning when the HDDs spin up/down.

And I agree with @sretalla on the fact that server HDDs should be running 24x7.
 

HarryMuscle

Contributor
Joined
Nov 15, 2021
Messages
161
Since Scale is Debian based it might be as simple as using an existing solution designed to work on Debian Linux. Here's one for example that can not only spin down the drives but also control fans based on drive temperatures: https://github.com/desbma/hddfancontrol

Thanks,
Harry
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
Seems no takers... I had a shot at it... I couldn't confirm if it's working or not, but it does run...
I'd take a stab but my Scale test rig has laptop drives installed and a few SSDs, none of which would be good to test a spin down with. I have been writing a fairly complex script that runs on both FreeBSD and Debian, a mixture of commands where required. Works well so far but the coding is ugly, but it works. I'd like to redesign it again and make it look better and have each routine be independent of the other routines. AWK kicks my butt at times. Everything else has been pretty easy.

A suggestion... To make it work for both FreeBSD and Debian, add the following statements:

at line 44 insert: softver=$(uname -s)
This will result on "softver" being equal to "FreeBSD" or "Linux".

And wherever you need to run a FreeBSD command or Linux command you add a simple if..then..else statement. It's never super simple when you have a lot of changes to make but the concept is simple.

if [ $softver != "Linux" ]; then
echo "Run the original FreeNAS code (FreeBSD)"
else
echo "Run the new Scale compatible code here (Linux)"
fi

See how much fun and now the program should work on both platforms.

For my little project I can't seem to find a way to make FreeBSD give me time with resolution to hundredths "hh:mm:ss.00" like I can in Linux.
 

justjasch

Dabbler
Joined
May 8, 2022
Messages
20
Hi there,
i tested the new script for Scale, its running but not spinning down the Drives.
I know that running Drives are mostly better, but i always have some Movie Lib. Drives wich are running only one Times a week for one hour... .

Manual with hdparm -y its working.

1652303793053.png


The scripts runs but never trigers. (the timers are set low for testing)
1652303601510.png



wbr Alex
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
You have moved the system dataset back to the SSD haven't you? If its on the HDD's they will never go to sleep.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Manual with hdparm -y its working.
Actually what you made obvious between that statement and the screen capture (lower and uppercase Y respectively) is that the lowercase y doesn't cut it.

I updated the script on the Git repo (or just edit line 225 to be uppercase Y) and give that a shot.

... side note, I still don't agree it's a good idea to use that script, but there are still those of you who want to and will, so I'm maintaining a (limited) interest.
 

justjasch

Dabbler
Joined
May 8, 2022
Messages
20
@NugentS Drives are empty and only put in for testing

@sretalla nothing changed with -Y, still no spindown

there are also some other Stuff. hdparm seems a little bit picky

3TB WD RED hdparm -C -Y works and reports

8TB Seagate ST8000DM004-2CX188
-C
/dev/sdp: "drive state is: unknown"
but sleep Command works and after -C "drive state is: standby"

SAS Western Digital Ultrastar DC HC550 18TB
-Y working but "SG_IO: bad/missing sense data, sb[]: 72 05 20 00 00 00 00 10 02 06 00 00 c0 00 00 00 03 02 00 00 80 02 f8 21 00 00 00 00 00 00 00 00" on -C

SAS HP 300GB 10000RPM EG0300FCHHR
-C with
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 16 00 00 00 00 20 00 00 00 00 00 80 0a 11 01 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 16 00 00 00 00 20 00 00 00 00 00 80 0a 11 01 00 00 00 00 00 00 00 00 00 00

-Y not working
HDIO_DRIVE_CMD(sleep) failed: Input/output error
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
OK, well there's not a lot of interest on my side to go into the minutiae of each different model of disk and make things work.

If you want to have a shot at adjusting the code (either on line 225 or around it) to something that works for each disk, have at it.
 

NugentS

MVP
Joined
Apr 16, 2020
Messages
2,947
@justjasch I think you missed my point - or maybe you didn't. If you have created a pool then the system dataset will have moved. The system dataset gets written to every few minutes. Make sure its on a set of SSD's if you want the HDD's to spin down
 

justjasch

Dabbler
Joined
May 8, 2022
Messages
20
@justjasch I think you missed my point - or maybe you didn't. If you have created a pool then the system dataset will have moved. The system dataset gets written to every few minutes. Make sure its on a set of SSD's if you want the HDD's to spin down
Yes its like this, those HDDs i put in a working system just for testing spindown, there is nothing on them, no Pool... .

@sretalla, i will have a Look an use the 3TB WD RED for testing
 
Top