hallo
ich habe ein script zum spindown meiner HDD in www gefunden. allerdings funktioniert das bei mir nicht richtig.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | # Specify any drives you want to ignore; separate multiple drives by spaces; e.g. "sda sdb" IGNORE_DRIVES="" PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' now=$(date +"%m_%d_%Y-%H-%M") # Check for idle disks and spin them down unless smartd is running tests # Create a file on the ramdisk and cycle it to test for disk activity ( if [ ! -f /dev/shm/diskstats_1 ] ; then touch /dev/shm/diskstats_1 /dev/shm/diskstats_2; fi ; mv /dev/shm/diskstats_1 /dev/shm/diskstats_2; cat /proc/diskstats > /dev/shm/diskstats_1 ) >/dev/null 2>&1 # Create tempfile for managing spun down disks TMP_OUTPUT="/tmp/spundown-disks_"$now"_temp" # Find all removable USB drives, so we can ignore them later, # see http://superuser.com/a/465953 REMOVABLE_DRIVES="" for _device in /sys/block/*/device; do if echo $(readlink -f "$_device")|egrep -q "usb"; then _disk=$(echo "$_device" | cut -f4 -d/) REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk" fi done # Append detected removable drives to manually ignored drives IGNORE_DRIVES="$IGNORE_DRIVES $REMOVABLE_DRIVES" # Loop through all the array disks and spin down the idle disks. Will find all drives sda -> sdz AND sdaa -> sdaz... for disk in `find /dev/ -regex '/dev/sd[a-z]+' | cut -d/ -f3` do # Skip removable USB drives and those the user wants to ignore if [[ $IGNORE_DRIVES =~ $disk ]]; then continue fi # Skip SSDs if [[ $(cat /sys/block/$disk/queue/rotational) -eq 0 ]]; then continue fi # Check if drive exists if [ -e /dev/$disk ]; then # Check if drive is currently spinning if [ "$(hdparm -C /dev/$disk | grep state)" = " drive state is: active/idle" ]; then # Check if smartctl is currently not running a self test if [ $(smartctl -a /dev/$disk | grep -c "Self-test routine in progress") = 0 ]; then # Check if drive has been non idle since last run if [ "$(diff /dev/shm/diskstats_1 /dev/shm/diskstats_2 | grep $disk )" = "" ]; then echo "/dev/$disk `df -h | grep /dev/$disk | rev | cut -d ' ' -f 1 | rev`" >> $TMP_OUTPUT hdparm -y /dev/$disk fi else echo "/dev/$disk is running Self-test routine" fi fi fi done |
soweit ich herausgefunden habe, liegt das Problem im letzten code-Block
1 2 3 4 | # Check if drive has been non idle since last run if [ "$(diff /dev/shm/diskstats_1 /dev/shm/diskstats_2 | grep $disk )" = "" ]; then echo "/dev/$disk `df -h | grep /dev/$disk | rev | cut -d ' ' -f 1 | rev`" >> $TMP_OUTPUT hdparm -y /dev/$disk |
hdparm -y /dev/$disk wird nur ausgeführt wenn /dev/shm/diskstats_1 und /dev/shm/diskstats_2 gleich sind. Am Beispiel /dev/sda sieht man das sie es aber leider nicht sind
1 2 3 | svenilee@gothamcity:~$ diff /dev/shm/diskstats_1 /dev/shm/diskstats_2 | grep sda < 8 0 sda 5966 1746 93093 137301 33 5 192 38841 0 101388 176682 0 0 0 0 19 539 > 8 0 sda 5950 1746 93083 136030 33 5 192 38841 0 100096 175411 0 0 0 0 19 539 |
ich verstehe nur nicht warum as so ist bzw. wie ich das Problem beheben kann.