coblck Posted March 5, 2021 Share Posted March 5, 2021 Hi can anyone tell me why my script wont work since update to 6.9, the script spins my drives up during busy time at time #!/bin/bash disks=$(ls /dev/md* | sed "sX/dev/mdXX"); for disknum in $disks; do /usr/local/sbin/mdcmd spinup $disknum; done below is error i get Script location: /tmp/user.scripts/tmpScripts/Spin Up Drives/script Note that closing this window will abort the execution of this script /usr/local/sbin/mdcmd: line 11: echo: write error: Invalid argument /usr/local/sbin/mdcmd: line 11: echo: write error: Invalid argument /usr/local/sbin/mdcmd: line 11: echo: write error: Invalid argument /usr/local/sbin/mdcmd: line 11: echo: write error: Invalid argument /usr/local/sbin/mdcmd: line 11: echo: write error: Invalid argument /usr/local/sbin/mdcmd: line 11: echo: write error: Invalid argument any help would be great Quote Link to comment
JorgeB Posted March 5, 2021 Share Posted March 5, 2021 Spin down is no longer handled by mdcmd but by emhttpd, not sure if there's a new command we can now use for spin up, I'm also interested in that. 1 Quote Link to comment
coblck Posted March 5, 2021 Author Share Posted March 5, 2021 Ah ok anywhere else we can post and ask ?? found it a very useful script Quote Link to comment
JorgeB Posted March 5, 2021 Share Posted March 5, 2021 For now you can wait to see if anyone else replies here. P.S. I edited the topic so the issue is more clear. 1 Quote Link to comment
SimonF Posted March 5, 2021 Share Posted March 5, 2021 (edited) sdspin in /usr/local/sbin is called by emhttp but i dont know of a replacement mdcmd way to spin up that the array knows about straight away. #!/bin/bash # # Deal with spin up/down status of HDDs # # This script is initiated from emhttpd, like so: # # sdspin <device> [up | down | status ] # # "device" is the HDD rdev name, such as "sdd". # # up == Spin the drive up # down == Spin the drive down # status == return the current status via rc # # Default (if no $2) is "status". # Exit code: # 0 - Success (if up/down), device spun up (if status) # 1 - Failure # 2 - Device spun down (if status) # Spin down/up SAS drives plugin # v0.85 # # (c) 2019-2021 @doron - CC BY-SA 4.0 It is also updated by doron's plugin to support SAS Drives. Edited March 5, 2021 by SimonF Quote Link to comment
coblck Posted March 6, 2021 Author Share Posted March 6, 2021 (edited) @JorgeB have you tried script above ?? Edited March 6, 2021 by coblck Quote Link to comment
JorgeB Posted March 7, 2021 Share Posted March 7, 2021 On 3/5/2021 at 7:28 PM, SimonF said: sdspin <device> up This works to spin up the disk, but it doesn't update the GUI status, so the disk won't spin down again. Quote Link to comment
coblck Posted March 7, 2021 Author Share Posted March 7, 2021 So the drive wont spin down after the default time has elapsed ?? Quote Link to comment
SimonF Posted March 7, 2021 Share Posted March 7, 2021 (edited) 24 minutes ago, JorgeB said: This works to spin up the disk, but it doesn't update the GUI status, so the disk won't spin down again. I have found that smartctl -iA /dev/sdh wakes a drive up and causes system to see active if you run it twice, as need IO against drive. But when Tom fixes Smartctl(6.9.1) issues it may not work. Edited March 7, 2021 by SimonF Quote Link to comment
JorgeB Posted March 7, 2021 Share Posted March 7, 2021 43 minutes ago, coblck said: So the drive wont spin down after the default time has elapsed ?? Correct. 24 minutes ago, SimonF said: I have found that smartctl -iA /dev/sdh wakes a drive up and causes system to see active if you run it twice, Thanks, worth a try. Quote Link to comment
JorgeB Posted March 7, 2021 Share Posted March 7, 2021 I guess another thing I can use is instead of just running the spin up script as I was doing before, change it to use sdspin <device> up and then run another script with sdspin <device> down, this achieves what I need. Quote Link to comment
coblck Posted March 7, 2021 Author Share Posted March 7, 2021 If you get a working scripted please let me know as this stuffs above my pay grade 😁 very much appreciated. Cheers lads Quote Link to comment
SimonF Posted March 7, 2021 Share Posted March 7, 2021 18 minutes ago, JorgeB said: sdspin <device> up You could use this and then do smartctl -A after for the IO. Quote Link to comment
JorgeB Posted March 7, 2021 Share Posted March 7, 2021 2 minutes ago, SimonF said: You could use this and then do smartctl -A after for the IO. Good idea. Quote Link to comment
JorgeB Posted March 7, 2021 Share Posted March 7, 2021 30 minutes ago, SimonF said: 49 minutes ago, JorgeB said: sdspin <device> up You could use this and then do smartctl -A after for the IO. This works for me. 47 minutes ago, coblck said: If you get a working scripted please let me know as this stuffs above my pay grade Basically you need to run a script that does: /usr/local/sbin/sdspin /dev/sdX up /usr/sbin/smartctl -A /dev/sdX Where X is replaced with the different array devices, ideally the script should get the device list from the array, since sdX can change when new controllers/devices are added, sometimes it even changes without any new ones, I'm not really a script guy, but it should be easy the get them, if not you can always do it manually, but need to be aware that they can change. 1 Quote Link to comment
coblck Posted March 7, 2021 Author Share Posted March 7, 2021 (edited) 41 minutes ago, JorgeB said: /usr/local/sbin/sdspin /dev/sdX up /usr/sbin/smartctl -A /dev/sdX So this will spin up all the drives or do i have to replace X with my drives allocation letter ? if so do i need to write the script for as much drives as i have ?? Edited March 7, 2021 by coblck Quote Link to comment
MightyT Posted March 8, 2021 Share Posted March 8, 2021 (edited) On 3/7/2021 at 3:05 PM, coblck said: So this will spin up all the drives or do i have to replace X with my drives allocation letter ? if so do i need to write the script for as much drives as i have ?? replace it and add the two lines per drive, that's what I'm using to keep two drives spinning: #!/bin/bash /usr/local/sbin/sdspin /dev/sdc up; /usr/local/sbin/sdspin /dev/sde up; /usr/sbin/smartctl -A /dev/sdc; /usr/sbin/smartctl -A /dev/sde; Edited March 8, 2021 by MightyT 1 Quote Link to comment
coblck Posted March 8, 2021 Author Share Posted March 8, 2021 Brill will try it this week once i get a minute, i take it they spin down if out with cron schedule ?? Quote Link to comment
MightyT Posted March 8, 2021 Share Posted March 8, 2021 According to their spindown schedule, yes. 1 Quote Link to comment
coblck Posted March 8, 2021 Author Share Posted March 8, 2021 Great many thanks have script repeating every 25 mins as spin down is at 30m so they are awake from 7pm to midnight on the weekend when plex is used most. Quote Link to comment
MightyT Posted March 9, 2021 Share Posted March 9, 2021 And it's not working anymore in 6.9.1, well sort of. It works but not only doesn't get the status reported with 'smartctl -A', the disk log even shows spinning down despite the script keeping them running. Any ideas anyone? Quote Link to comment
coblck Posted March 9, 2021 Author Share Posted March 9, 2021 Will leave it on 6.9 for now till a workaround is fixed Quote Link to comment
SimonF Posted March 10, 2021 Share Posted March 10, 2021 18 hours ago, MightyT said: Any ideas anyone Need to look at some other way to generate DiskIO at a partition level as 6.9.1 is discounting at a disk level to allow spin down. What is the use case, can you provide me with a bit of a back ground on what you need to do? Quote Link to comment
coblck Posted March 10, 2021 Author Share Posted March 10, 2021 Where looking at getting the discs to spin up at a certain time of day and staying spun up. Quote Link to comment
MightyT Posted March 10, 2021 Share Posted March 10, 2021 For now I just 'cat' a small txt file for each disk, that wakes the disks up and refreshes the status, I'm hoping this keeps them spinning since there is no read caching that I'm aware of. Use case is, like coblck said, keeping the disks spun during a certain time of day while having relatively strict spindown settings at other times. For me it is too noisy while I'm working (and rarely accessing anything), and then in the evening and on the weekends I just want to keep them spinning since I'm not in the room aynway, to reduce spinup/spindown cycles. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.