Trouble

hdparm and SATA HDD

8 4494
Gigglo  
Post Last Edited by Gigglo at 2014-10-6 08:31

Post Last Edited by Gigglo at 2014-10-4 09:01

Post Last Edited by Gigglo at 2014-10-4 09:00

Hi,

what do I have to do, to spin down the SATA HDD?
Tried it with hdparm with the parameter in the /etc/rc.local:
  1. /sbin/hdparm -Y180 /dev/sda
Copy the Code
But I guess this has no effect.
  1. sudo hdparm -C /dev/sda
Copy the Code
gives out:
  1. /dev/sda: drive state is:  standby
Copy the Code
But when the entry
  1. /sbin/hdparm -Y180 /dev/sda
Copy the Code
is deleted there is exactly the same:
  1. /dev/sda: drive state is:  standby
Copy the Code
Furthermore I don't think that the HDD is really in the standby mode, 'cause it seams to spin all the time, there is apparently no standby.  

Do you have a solution?

Thanks and regards
ryad  
Have you tried hdparm -S 120 /dev/sda ? This should spindown your drive in 10 minutes if your drive supports that feature.

Gigglo  
Hi ryad,

your solution seems to work. Thanks!

Kulli  
Hi,
unfortunately, this doesn't work for me on Lubuntu (Image 3.1.1).
After
  1. hdparm -S 2 /dev/sda
Copy the Code
and the confirmation "setting standby to 2 (10 seconds)" the drive still keeps spinning.
Also, I noticed that the settings which can be done through the menue preferences --> disks --> drive settings --> standby don't have any effect.
What is wrong with my banana pi?

Many new drives ignore the spindown timeout.   I use this script to detect if a drive is idle and spin it down:

http://craiger.org/spindown.sh

Kulli  
Thanks edfardos! Your script works like a charm! You should consider posting the source code here, just in case you take it offline some day.

For everybody else: There are instructions in the script, how to use it. If you decide to use it, you should set up the cronjob FOR THE ROOT USER!

Thanks, again!

#! /bin/bash
# Check for idle disks and spin them down
# run this from cron every 30 mins
#     */30 * * * * /usr/local/bin/spindown.sh
#  -- craiger, parts taken from Zack Reed

# space separated list of disk wwn names to monitor.
# These should be found in /dev/disk/by-id:
DISKNAMES="wwn-0x5000cca222d23f5f "




export PATH=$PATH:/sbin:/usr/sbin

# Create a file on the ramdisk and cycle it to test for disk activity
( if [ ! -f /dev/shm/1 ] ; then touch /dev/shm/1 /dev/shm/2; fi ; mv /dev/shm/1 /dev/shm/2; cat /proc/diskstats > /dev/shm/1 ) >/dev/null 2>&1

date

# convert disk wwn id's into sdX names because kernel developers
# think they're so clever and randomize sd* names at boot, while most
# userspace tools assume they're static, including /proc/diskstats
for id in $DISKNAMES
do
  SDLIST="$SDLIST `readlink /dev/disk/by-id/$id | cut -d/ -f3`"
done

# Loop through all disks and spin them down if idle.
for disk in $SDLIST
do
  # Check if disk exists
  if [ -e /dev/$disk ]; then
     # Check if disk is currently spinning
     if [ "$(hdparm -C /dev/$disk | grep state)" = " drive state is:  active/idle" ]; then
         #Check if disk has been accessed since last time
         if [ "$(diff /dev/shm/1 /dev/shm/2 | grep $disk )" =  "" ]; then
            echo "Drive $disk is spun up and idle.  Spinning down now."
            hdparm -y /dev/$disk
         else
            echo "Drive $disk is spun up and being accessed.  No change."
         fi
     else
        echo "Drive $disk is already spun down.  No change."
     fi
  else
     echo "Drive $disk not found."   #will never happen
  fi
done

gtFlue  
Does this script work for any drive, or does the DiskNames need to be updated to match your drive?

When I run this manually I get a time stamp return and nothing seems to happen with the drive.

Thanks.

you must provide your disk's particular wwn-id in "DISKNAMES"

You have to log in before you can reply Login | Sign Up

Points Rules