System Hibernate after x minutes of inactivity - how?

flashdrive

Patron
Joined
Apr 2, 2021
Messages
264
goal:

safe electric power (bill)

howto:

systemctl suspend (to RAM)

or hibernate (to disk)


How can I achieve for TrueNAS SCALE to go to suspend moder after x minutes of inactivity?

Is there a setup option out of the box?
Script?

How to determine if its "safe" for the system to go to hibernate, i.e. not during a scrubbing?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
You're probably best to raise a feature request for this in Jira and try to get a bunch of people to upvote it.

Since TrueNAS is designed for servers that would normally operate 24/7, this isn't a feature that is in any part of the design process at this point.

Anything you would do in order to fudge things like you mentioned (checking for active tasks, etc.) would potentially be thwarted by any update unless you go by the method I mentioned.
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
How to determine if its "safe" for the system to go to hibernate, i.e. not during a scrubbing?

The basic problem is that your concept of "safe" is a locally-defined idea of what the local administrator (you) believes is safe.

Generally speaking, it is never safe for a FreeNAS/TrueNAS host to hibernate, because this will cause it to miss access attempts from clients, running other background tasks, SMART checks, scrubs/resilvers, replications, and a lot of other stuff. Additionally, spinning drives up and down is very stressful on the drives and the host system, which places your data at additional risk.

With that said, I'm sure that you believe it is fine to do this anyways because of your particular low-demand circumstances, which is fine, but the point is that over the hundreds of times this has been suggested in the history of this forum, there hasn't been a consistent set of conditions presented that represent a "good time" to idle. Do you hibernate just because no activity has been seen in, let's say, ten minutes? What about the SMB connection that is currently open to a PC where a user is editing a file but not causing any disk I/O right now? Most of this is really dependent on your local definition of what constitutes an "idle" system and what sorts of compromises you are willing to make.

You're probably best to raise a feature request for this in Jira and try to get a bunch of people to upvote it.

Since TrueNAS is designed for servers that would normally operate 24/7, this isn't a feature that is in any part of the design process at this point.

So basically this has been a nonstarter every time the suggestion has come up, not because it's technically impossible to hibernate a system, but really because it's a lot of time and trouble to code in for an edge case that's a bad idea to begin with. And then of course, if you did code it in, you invariably get the folks who are unhappy with the design tradeoffs chosen by the developers, or are running it on janky hardware where the support isn't quite right, etc., and it turns into a real rabbit hole. The developers have typically avoided rabbit holes like on-host firewalling, WoL, hibernation, etc., because this is definitely NOT relevant to their enterprise product.

What you CAN do, however, is write and run a script every five minutes to check if the system is in a state where you believe that it could be hibernated, and then call the hibernation if it met your criteria. There is also nothing stopping you from sharing that, and I'm positive that it could be posted on Github or as a resource here on the forums.
 

flashdrive

Patron
Joined
Apr 2, 2021
Messages
264
@sretalla
@jgreco

I have started to look into this


In the end it comes down to this:

If the "saved expense on electricity bills" is neglectable by hardware wear and tear and also the leisure time invested then one needs to decide which road to choose.

How much is your time worth to you personally? All I can say is that if I had bought an off the shelf solution it would have saved me so much time - but I wouldn't have learned half as much.

In the end I am a FreeNAS long termer: I am a translator of the very old FreeNAS system back in the day when ZFS became implemented in FreeBSD.
 
Last edited:
Top