January 14, 200917 yr Just wondering if the below feature could be added (only if it isn't too much to ask). At present we have both a global and per disk spin down delay which is fantastic however I can't help but wonder if we could also add to this feature by allowing for different spin down delays depending on what time of day it is. For instance during the day when I am likely to be using the files on my array I wouldn't mind having auto-spin-down disabled. However if it is say 11pm at night and no activity is detected for an hour then it would be good for the drive to spin down for the night and stay spun down until it is accessed again. The above is just one idea that I am expressing out loud. At present I don't use a cache drive (no more room in my case) but I imagine if I did, then the whole scheduled transfer of files at night time would also be a good time to activate a shorter disk spin down schedule. For households where nobody is home during work hours, this idea might be extended to differ depending on what day of the week it is. Many torrent/usenet clients employ a scheduler table which might be useful however I am not sure how easy it is to implement such a feature with the current web GUI so propose something simpler instead. In case my thoughts above are not very clear, an example is provided below. Disk spin down settings: Global Disk spin down delay: [Never/15min/30min/45min/1hour/2hour etc.] Disk spin down schedule: Start Time | End Time | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday 23:00 18:00 X X X X X 23:0009:00XX So according to the above, Disk spin downs delays are enforced starting at 11pm and staying in force until 6pm the following day (when one gets home from work) on weekdays, and for weekends, the disk spin down delays are enforced starting at 11pm and staying that way til 9am the following day. Hope the above is clear. Welcoming all comments and criticisms.
January 16, 200917 yr Let me second that. I would be happy with a single time frame to stop all drives in the night and keep them running all day - but a matrix-like schedule brings it to the max. Thanks. Harald
January 16, 200917 yr since 4.4.2 has individual spin times for each drive, something "probably" could be cooked up by the AWK Geniuses with cron....
January 16, 200917 yr since 4.4.2 has individual spin times for each drive, something "probably" could be cooked up by the AWK Geniuses with cron.... All you really need do is turn your logic perspective around. Schedule the spin-down on all disks when idle for 60 minutes or more. Then, using cron in combination with "dd" schedule a "read" of each of your drive you want spinning every 30 minutes or so during the day on those days you want to keep it spinning. Here is a short script to spin up a drive (notice, no "awk" was used at all) I named it spin.sh [pre] #!/bin/bash USAGE="Usage: $0 /dev/aaa /dev/bbb /dev/ccc ... /dev/zzz" if [ "$#" == "0" ]; then echo "$USAGE" exit 1 fi while (( "$#" )); do if [ ! -b $1 ] then echo $1 is not a disk drive exit 2 else i=$1 fi # spin up by reading a single "random" block from each disk # We use "dd" commands in the background so # all the disks will be spun up in parallel # determine the number of blocks on the drive blocks=`df -k $i | grep -v Filesystem| sed "s/\([^ ]*\) *\([^ ]*\) .*/\2/"` # calculate a (random) block number to be read somewhere # between block 1 and the max blocks on the drive skip_b=$(( 1+(`dd if=/dev/urandom count=1 2>/dev/null | cksum | cut -f1 -d" "`)%($blocks) )) # read the random block from the disk. We use a random # block to try to ensure it is not in the cache memory # if the block was in the cache memory, the disk would # not spin up. dd if=$i of=/dev/null count=1 bs=1k skip=$skip_b >/dev/null 2>&1 & shift done [/pre] Then, all you need to do is invoke it as desired with as many cron entries as needed. For example: # Monday through Friday. keep drives hdb, hdc, sdd spinning from 6:00 PM to 11:00 PM 0 18-22 * * 1-5 /boot/custom/bin/spin.sh /dev/hdb /dev/hdc /dev/sdd 30 18-21 * * 1-5 /boot/custom/bin/spin.sh /dev/hdb /dev/hdc /dev/sdd # Saturday and Sunday, keep drives spinning all day 0 9-22 * * 0,6 /boot/custom/bin/spin.sh /dev/hdb /dev/hdc /dev/sdd 30 9-21 * * 0,6 /boot/custom/bin/spin.sh /dev/hdb /dev/hdc /dev/sdd Edit: fixed crontab syntax... (repeat to self) minutes first, then hours... Joe L.
January 16, 200917 yr Note that I do the last "spin up" of a disk an hour prior to the expected spin down time at 22:00. On the half hour, I do the last at 21:30. (If I did one at 22:30, and if the disk had a 1 hour spin-down timeout, the disk would not spin down until 23:30 ) Joe L.
January 17, 200917 yr Joe, I'm not sure that this is correct. Consider a bad block that becomes corrected by the drive, will this be reflected in parity when using devices itself (/dev/sdx)? Thanks Harald
January 18, 200917 yr Joe, I'm not sure that this is correct. Consider a bad block that becomes corrected by the drive, will this be reflected in parity when using devices itself (/dev/sdx)? Thanks Harald You should never write to one of the "raw" drives... It is perfectly OK to read from them the way I did in the example spin-up script. I am not worried about a bad block being corrected by parity, as I am just throwing away what I've read by sending it to /dev/null. In fact, I have no idea if the random block being read is part of a file, part of the file-system-structure, or empty space on the drive. It really does not matter. The "read" does exactly the same as any other access of the drive, the disk driver spins up the drive if the data is not in the buffer cache. By reading a "random" block of data each time, the odds of it being in the cache is almost zero. Tom's spin-down process is reading the disk read statistics, so it will see the activity and not spin the disk down until it sees a period of time with no activity. That should occur around 23:00 if no movie is being played. Joe L.
January 18, 200917 yr Author Thanks for all the suggestions guys. Being a total linux newbie I'll be slowly digesting what was written. It seems like a good opportunity to get my hands dirty on something that I'd find useful.
January 18, 200917 yr Hi Joe, sorry, but I can't get it to work. This is part of my "crontab -l" output: 8-23 0 * * * /boot/jobs/spin.sh /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo /dev/sdp 8-23 30 * * * /boot/jobs/spin.sh /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo /dev/sdp My drives still spin-down. However, if I issue the command manually it works. What's the magic behind unRAIDs crontab? Thanks Harald
January 18, 200917 yr Hi Joe, sorry, but I can't get it to work. This is part of my "crontab -l" output: 8-23 0 * * * /boot/jobs/spin.sh /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo /dev/sdp 8-23 30 * * * /boot/jobs/spin.sh /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo /dev/sdp My drives still spin-down. However, if I issue the command manually it works. What's the magic behind unRAIDs crontab? Thanks Harald You just need to do what I meant, not what I said... The "minutes" come first, then the hours in the crontab. My example was flawed, you just copied it. Neither parsed properly and they were rejected by cron. Try 0 8-23 * * * /boot/jobs/spin.sh /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo /dev/sdp 30 8-23 * * * /boot/jobs/spin.sh /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo /dev/sdp You could combine both by typing: 0,30 8-23 * * * /boot/jobs/spin.sh /dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo /dev/sdp Joe (I'll just go hang my head in shame) L.
January 18, 200917 yr Joe (I'll just go hang my head in shame) L. no, no, don't do that. I could do that too. I've filled so many crontabs - I didn't find it. I included it in my go script and with this EOF stuff I was so busy I didn't look at the syntax. Thanks a lot. Harald
Archived
This topic is now archived and is closed to further replies.