What's new

Spining Down function

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

gjf

Senior Member
Following up spinning down function that was discussed already a number of times.

Merlin firmware allows to exclude some drives for this feature - and it is useful when few drives are connected especially when one of them is used for Entware/Optware.

But unfortunately in uses only marks like sda/sdb/sdc/etc. The problem appears with few connected drives because the sequence they are connecting can be different - and sda can become sdb after reboot.

If the drive contains only one partition - partition UUID can be used to identify the drive, but it is not possible to set it for spin down function.

Is there any way to use UUID for spin down exclusions?
 
No. sd-idle works at the device level, not at the filesystem level. It needs a device name.
 
Pity. OK, have to disable it in this case,

You could potentially handle sd-idle yourself, through a post-mount script. Retrieve the device name from that script, then run sd-idle yourself with the appropriate device name.
 
I have no idea how to work with sd-idle actually.
So I see only two options for me:
1. Disable the feature.
2. Enable it for all drives. Taking into account Entware and swap are on flash drive and HDD is only file storage - I don't think spin down will affect flash drive (as it doesn't support it at all).
 
Just out of curiosity I have tried to create a post-mount script. Something like:
Code:
#!/bin/sh

if [ "$1" = "/tmp/mnt/HDD" ]
 then
   service stop_sd-idle-2.6
   service start_sd-idle-2.6 -d .........
fi

The main problem is "......." Sure I can handle the moment when HDD is mounted but how to convert it back to appropriate device name?
Sure in this case I have to exclude all disks in web interface (because I enable it in post-mount manually) - but will this setting remain after reboot taking into account manual eneabling every time in post-mount?
 
Retrieve the device name with something like this:

Code:
#!/bin/sh
tempo="/mnt/KT410"

DEVICE=$(mount | grep $tempo | cut -f 1 -d " ")

echo "device: $DEVICE"
 
Retrieve the device name with something like this:

Code:
#!/bin/sh
tempo="/mnt/KT410"

DEVICE=$(mount | grep $tempo | cut -f 1 -d " ")

echo "device: $DEVICE"
Thanks for idea, and actually this one is even more useful:
Code:
#!/bin/sh
tempo="/mnt/HDD"
DEVICE=$(mount | grep $tempo | cut -f 1 -d " ")
echo ${DEVICE:7:1}

The question about sd-idle-2.6 is still open nevertheless.

1. Will service start_sd-idle-2.6 -d ${DEVICE:7:1} work OK in the case when all drives are disabled for spin down in web interface?
2. Will all settings be reverted back after reboot? I mean will all drives be disabled or the system will "remember" inclusion from our manual restart from previous booting?

Sure the best way would be some script to disable all drives for sd-idle and restart it with only one drive enabled - but I have no information how to do it.
 
Last edited:
Simply don't enable sd-idle at the webui level, and handle it strictly through that script, taking care of running the binary yourself with the necessary parameters. I have no idea how sd-idle will react to being run multiple times with different parameters however, you will have to try it.
 
OK, looks like I found the way to handle this.

The post-mount script is as follows:
Code:
# This part corresponds to spin down mechanism
# Put it in the very end of your post-mount file
# HDD is the path to HDD disk to be spinned down
HDD=/mnt/VERBATIM_HD
DISKEXCLUDE=abcdefghijklmnopqrstuvwxyz

DEVICE=$(mount | grep $HDD | cut -f 1 -d " ")
killall -q - sd-idle-2.6
sleep 10
sd-idle-2.6 -i 900 -c 30 -d !${DISKEXCLUDE//${DEVICE:7:1}/}
I have put a 10 second pause after killall command to be sure the process terminates successfully before restarting. Killall is added just to be sure also.
Because of pause I suggest to put this piece of code in the very end of post-mount script to avoid unnecessary pause of other processes those could exist in post-mount.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top