Extend hibernation features (2h and also a 'toggle' QPKG)

Tell us your most wanted features from QNAP products.

Extend hibernation features (2h and also a 'toggle' QPKG)

Postby Briain » Thu Jan 27, 2011 8:46 pm

Hi

I wonder if there would be a broader appetite for a feature I'd really like to have (again, I've added two related ideas to this one post):

A toggle hibernation enable/disable button

I would like to either disable hibernation, but to have the facility to hit a button to spin the disks down (say, 10 minutes or so after pressing it) or to have a button assignment which toggles hibernation between enabled and disabled. My thoughts would be to either make this a momentary press of the power button, or provide a user option to re-assign then copy button (which I never use anyway); maybe this could even be a QPKG idea?

My usage entails regular access to the NAS through the day and evening (sometimes just by powering up a PC on the network) and thus the NAS ends up cycling the disks up and down several times a day. My preference would be that once it has spun up, to have it remain spun up, but to also have a way to simply press a button to hibernate it until next required (so you could press a button at night, then it would spin down until next accessed). The most sensible option might be to assign the button to toggle hibernation enabled or disabled state (and you could manually set hibernation to whatever suits you) as that'd give the best of all worlds.

It could be that I am the only person who'd ever wish that feature, but if I see a use for use it, my guess is that there might be others who'd like it too, and it were easy enough to design, it might be a really cool idea for a new QPKG.

Additional hibernation time choices

Separate to that idea, I think it might be useful to add more time options to the existing hibernation feature (maybe new 90 minutes and 120 minutes options). If there were a slightly longer option than is currently offered, it would save pointless spin up/down cycling through the day, but still leave a worthwhile hibernation period over night.

Bri
User avatar
Briain
Been there, done that
 
Posts: 760
Joined: Tue Apr 20, 2010 11:56 pm
Location: Edinburgh (Scotland)
NAS Model: TS-459 Pro

Re: Extend hibernation features (2h and also a 'toggle' QPKG

Postby micke » Sat Jan 29, 2011 10:28 pm

Briain wrote:A toggle hibernation enable/disable button

If you call /sbin/hdsuspend -a -t 0 then it should disable the standby timeout for the drives. With /sbin/hdsuspend -a -t TIMEOUT you should be able to set a timeout for all drives. If the hdparm application uses a standard implementation of the standby feature the values from 1 to 240 should specify multiples of 5 seconds (i.e. timeouts from 5 seconds to 20 minutes), 241 to 251 in 1 to 11 units of 30 minutes, 252 a timeout of 21 minutes, 253 vendor specific (8 to 12 hours), 254 is reserved, and 255 is a timeout of 21 minutes plus 15 seconds.

Using this information you could create a QPKG that sets a short timeout when enabled and disable the standby when the QPKG is disabled. Or you could use my QPKG that makes it possible to re-define the copy button and run user-defined scripts.

/Mike
micke
Experience counts
 
Posts: 1350
Joined: Sat Feb 06, 2010 2:42 pm
Location: Taipei, Taiwan
NAS Model: TS-239 Pro

Re: Extend hibernation features (2h and also a 'toggle' QPKG

Postby Briain » Sun Jan 30, 2011 3:28 am

Hi

You're a star! That reassign copy button QPKG sounds perfect! I've used hdparm before (to sort my QNAP when there was a spin down bug in an earlier firmware; you couldn't disable Qnap's hibernation feature) but I have thought about writing scripts for that.

Thank you for the ideas and for making that copy button reassignment QPKG; that's just absolutely marvellous! :)

Bri

PS Maybe I need to reassign the copy button to call /sbin/hdsuspend -a -t 0 and reassign the power button to set sbin/hdsuspend -a -t TIMEOUT to 60 (assuming it's set in minutes); that'd be pretty much perfect. I'll ask my Linux friend if a script can be made to enable a single button to toggle it between the two. :)
Last edited by Briain on Sat Feb 12, 2011 1:09 am, edited 1 time in total.
User avatar
Briain
Been there, done that
 
Posts: 760
Joined: Tue Apr 20, 2010 11:56 pm
Location: Edinburgh (Scotland)
NAS Model: TS-459 Pro

Re: Extend hibernation features (2h and also a 'toggle' QPKG

Postby Briain » Sun Jan 30, 2011 5:05 am

Or, I could leave it set to 60 minute spin down, then use your QPKG copy button reassignment QPKG to start a 'keep alive' script which briefly accesses the disks every 55 minutes (maybe just 'touch' a file). pressing it again would stop the accesses and thus enable it to spin down after 1h. I guess that would probably be classed as cheating (and I'd much rather do it the more 'correct' way and toggle sbin/hdsuspend -a -t if possible). :D

Bri
User avatar
Briain
Been there, done that
 
Posts: 760
Joined: Tue Apr 20, 2010 11:56 pm
Location: Edinburgh (Scotland)
NAS Model: TS-459 Pro

Re: Extend hibernation features (2h and also a 'toggle' QPKG

Postby micke » Sun Jan 30, 2011 5:29 am

micke wrote:the values from 1 to 240 should specify multiples of 5 seconds ...

The values to hdsuspend seems to be in multiples of 1 minute (it calls hdparm internally with the correct timeout value; truncating to a valid value).
Briain wrote:PS Maybe I need to reassign the copy button to call /sbin/hdsuspend -a -t 0 and reassign the power button to set sbin/hdsuspend -a -t TIMEOUT to 60 (assuming it's set in minutes);

Maybe something like this for the copy button
Code: Select all
#!/bin/sh

if [ -f /share/OTR/.standby ]; then
        /sbin/hdsuspend -a -t 0
        /bin/rm /share/OTR/.standby
else
        /sbin/hdsuspend -a -t 60
        /bin/touch /share/OTR/.standby
fi

Press it once and the timeout value is set to one hour; press it again and it is disabled.

/Mike
micke
Experience counts
 
Posts: 1350
Joined: Sat Feb 06, 2010 2:42 pm
Location: Taipei, Taiwan
NAS Model: TS-239 Pro

Re: Extend hibernation features (2h and also a 'toggle' QPKG

Postby Briain » Sun Jan 30, 2011 5:42 am

Hi Mike

Thank you very much for taking the time to respond with that script; it is most appreciated! I'll give it a whirl tomorrow, see what happens, then let you know how I get on. :)

Kind regards
Bri
User avatar
Briain
Been there, done that
 
Posts: 760
Joined: Tue Apr 20, 2010 11:56 pm
Location: Edinburgh (Scotland)
NAS Model: TS-459 Pro

Re: Extend hibernation features (2h and also a 'toggle' QPKG

Postby Briain » Thu Feb 10, 2011 7:22 pm

Hi Mike

This is excellent! I've been using it for a week now and it has worked flawlessly. It took me a while to get it going and I felt like kicking myself when I discovered why; I wasn't pressing the button long enough to start it :)

I've added beeps to notify me that it's accepted the press and is thus running the script. When toggled to hibernate on, it responds with a short then long beep (the Morse code for 'N' as in good Night). Adding the beeps to Mike's suggested standby toggle script results in the below:

Code: Select all
#!/bin/sh

if [ -f /share/OTR/.standby ]; then
      /sbin/pic_raw 80   Beep short
      /bin/rm /share/OTR/.standby
      /bin/sleep 20
      /sbin/hdsuspend -a -t 0
      /sbin/pic_raw 80   Beep short
else
      /sbin/hdsuspend -a -t 20
      /bin/touch /share/OTR/.standby
      /sbin/pic_raw 81   Beep long
      /bin/sleep 1
      /sbin/pic_raw 80   Beep short
fi


I've set it to 20 minutes, which in reality, equates to about 30 minutes before it actually spins the disks down (remember that pressing the button activates the script and thus accesses the disks, so you can time spin down from that event).

Bri

-----------------------------------------------------------

Update

A couple of folks from the Linn forum have contacted me to ask about how to use this script, so to clarify things, the best way to set it up is summarized below:

Create a new share (via the Qnap web interface) called OTR, then drop the above script into it, then install Mikes copy button remap QPKG; that's it done! Just to make things quicker for folks, I've attached the above script in a zip file (open it and drop the togglesnooze.sh file into the OTR share).

How I drive it

Obviously, it still spins the disks up in the normal way when required, but when I'm on the way through to my lounge to play some music (or my office to do some work; though that's a pretty rare event) I hit the copy button on my Qnap and it runs the script (initially waking up one disk or more) and the NAS beeps immediately (to acknowledge I've pressed the button for long enough), then the remaining disks start up after a few more seconds. It actually waits for all the disks to have spun up (and for everything to have settled down) before actually applying the new 'hibernation off' settings, which is completely unnecessary, but it's also completely harmless, so I've just left it in there; I wanted to attach the actual script that I've been successfully using for a couple of weeks.

Last thing at night, I hit the button again (and it beeps the Morse code for 'N') and hibernates after about half an hour after the button press.

Thanks again to Mike for both the OTR QPKG and all his help with this; is very useful as it saves my disks spinning up and down several times per day and enables the NAS to hibernate over night (and until next accessed, or when I push the toggle button to keep it alive).

Rbi
You do not have the required permissions to view the files attached to this post.
User avatar
Briain
Been there, done that
 
Posts: 760
Joined: Tue Apr 20, 2010 11:56 pm
Location: Edinburgh (Scotland)
NAS Model: TS-459 Pro

Re: Extend hibernation features (2h and also a 'toggle' QPKG

Postby Briain » Thu Mar 22, 2012 2:40 am

Hi

I've revised the script to now do the below (the script is attached in a zip file at the end of this post):

Code: Select all
#!/bin/sh

if [ -f /tmp/disableStandby ]; then
      /sbin/hdsuspend -a -t 20
      /bin/rm /tmp/disableStandby
      /sbin/pic_raw 81   Beep long
      /bin/sleep 1
      /sbin/pic_raw 80   Beep short
else
      /sbin/pic_raw 80   Beep short
      /bin/touch /tmp/disableStandby
      /bin/touch /share/OTR/.SpinUpNow
      /bin/sleep 20
      /bin/rm /share/OTR/.SpinUpNow
      /sbin/hdsuspend -a -t 0
      /sbin/pic_raw 80   Beep short
fi


Reasons below:

This means that when you reboot the NAS, the file will be removed from /tmp and thus pressing the button will always cancel hibernation (before, it depended on what state you'd left it in before rebooting it).

As the file is now in /tmp, pushing the button no longer spins the disks up (/tmp/disableStandby is in memory) so I added the line to create (then delete) the .SpinUpNow on the OTR share (so it writes to the disk and thus actually spins them up).

Bri :)


PS New firmware (3.7.3) has enhanced the feature set of the copy button and it now requires something to be plugged into the front USB port before the button acts on Mike's OTR script; there is an easy solution discussed here (plug in a £3 very low profile USB stick).
You do not have the required permissions to view the files attached to this post.
Last edited by Briain on Sun Sep 09, 2012 6:46 pm, edited 2 times in total.
User avatar
Briain
Been there, done that
 
Posts: 760
Joined: Tue Apr 20, 2010 11:56 pm
Location: Edinburgh (Scotland)
NAS Model: TS-459 Pro

Re: Extend hibernation features (2h and also a 'toggle' QPKG

Postby Zoggeh » Fri Aug 17, 2012 2:03 am

Does this script work for TS-412 running 4 disks in a raid 5 configuration, as when I try to run it manually and debug why it is not working the /sbin/hdsuspend command brings back the following error:

Code: Select all
 SCSI_IOCTL_SEND_COMMAND(setidle1) failed : Inappropriate ioctl for device
 SCSI_IOCTL_SEND_COMMAND(setidle1) failed : Inappropriate ioctl for device
 SCSI_IOCTL_SEND_COMMAND(setidle1) failed : Inappropriate ioctl for device
 SCSI_IOCTL_SEND_COMMAND(setidle1) failed : Inappropriate ioctl for device


Any help would be appreciated.

Regards

Z
Zoggeh
New here
 
Posts: 4
Joined: Tue Aug 14, 2012 8:22 pm
NAS Model: TS-212

Re: Extend hibernation features (2h and also a 'toggle' QPKG

Postby Briain » Mon Nov 26, 2012 7:42 pm

Hi

Sorry for taking ages to respond but I have only just noticed your post.

I get various errors when triggering my script from the CLI, but they are not the same as you are seeing. Below shows an example of my TS-659 where there are 4 disks fitted (in RAID 6) and two empty slots:

[~] # /share/OTR/togglesnooze.sh
HDIO_DRIVE_CMD(setidle1) failed: Input/output error
HDIO_DRIVE_CMD(setidle1) failed: Input/output error
HDIO_DRIVE_CMD(setidle1) failed: Input/output error
HDIO_DRIVE_CMD(setidle1) failed: Input/output error
/dev/sde: No such device or address
sde set fault
/dev/sdf: No such device or address
sdf set fault
[~] #


I also get the 'failed: input/output error' messages when running the script on my TS-219P+ and my TS-119P+, but the script works fine on all three NAS's. My assumption is that when setting hibernation via the Qnap web interface, it likely uses the same process (so setting it to 30 minutes would likely generate /sbin/hdsuspend -a -t 30) but I've not looked deeply into how it's done via the web interface (I've not tracked down the script that accesses). My guess would be that if so, a similar message will be generated but obviously you won't see it.

I don't know what would generate the 'Inappropriate ioctl for device' message, but I wonder if it could just be that it isn't recognising the time value you are using. Did you pick an odd value for the time, or did you try the script as it is (set to 20 minutes)? If you changed it, maybe try it as it is (20 minutes) to see if that behaves differently.

Bri
User avatar
Briain
Been there, done that
 
Posts: 760
Joined: Tue Apr 20, 2010 11:56 pm
Location: Edinburgh (Scotland)
NAS Model: TS-459 Pro


Return to Features Wanted

Who is online

Users browsing this forum: packleds and 3 guests