search

Understanding GoFlex Home Spindown

Why won't my disk ever stop spinning? Why is my GoFlex Home slow to respond and how can I increase the delay before it goes to sleep? What do the pwrmgr conf settings mean? Why does the disk even need to spin down at all? This post tries to answer those questions.

What is spin down?


While the hard disk is spinning at upwards of 90 revolutions per second it is slowly wearing out as well as using power, so it makes sense to stop spinning when it is not being accessed.
The downside of that is that next time you want to read or write to the disk it has to spin up again before you can do that so there is a small delay, plus repeatedly spinning up causes more wear and power usage than spinning continuously. So spin down settings that suit one user may not suit someone else. And that is why the setting are configurable.

The time before the drive will wait before spinnning down when it is idle is set in /etc/pwrmgr.conf. The default is idletime=30, meaning 30 minutes.

There are other settings in pwrmgr.conf which are ignored or commented out. It seems that there is a power schedule possible, but this has been disabled on the GoFlex Home. As far as I can tell the idea is to power down the hard drive based on a schedule, but I won't be going into that in this post.
enabled=false

# timed shutdown/poweron unsupported on seagate plug
# day0tim0=1000
# day0evt0=1
# day0tim1=2200
# day0evt1=0

# day1tim0=1000
# day1evt0=1

How does the GoFlex Home spin down timer work?


During boot initialization, the /etc/init.d/spindownd.init script is run with the start option. That in turn starts the /usr/sbin/spindownd process which should stay running as long as your goflex home is powered up. 

/usr/sbin/spindownd is a small program that loops indefinitely.
first it gets the idle time setting from /etc/pwrmgr.conf. 
It does that by getting any characters immediately after the Idletime= in tne pwrmgr.conf file and multiplying that by 60 to convert seconds to minutes.
So if you edit the pwrmgr.conf file don't enter anything except numbers after =  
That means no spaces before or after and no comments on the same line.

Next it finds all the attached hard drives by checking the /dev directory for devices starting with "sd" . 
Then for each of those devices it gets stats from  /sys/block/, for example for your primary drive sda it will read /sys/block/sda/stat for read I/Os and write I/Os

It compares those values against global variables in memory
If the numbers are different to last time it checked, meaning the drive is still being used, it stores the I/O numbers as well as the time of the check in global variables.

But if the values are the same, meaning the drive hasn't been accessed since last check then it compares the current time against the time the numbers last changed and if the time difference is greater than the idle time setting in pwrmgr.conf then it sends the hdparm spindown command /sbin/hdparm -y /dev/$dev
The  -y flag forces the drive to immediately enter the low power consumption standby mode, causing it to spin down.

Then spindownd sleeps for 30 seconds and then goes through the loop again.

So in summary, every 30 seconds it checks to what drives are attached and whether they have been accessed and spins them down if the time since they were last accessed is greater than the idletime setting.


Ok so why isn't my drive spinning down?


1. Is the spindownd process running?
The first thing, just to get it out of the way is to check that spindownd is actually running with
 ps -A | grep spindownd  which should return something like  
2545 ?        00:00:03 spindownd
The first number (in this case 2545) is the Process ID

2. Is a process reading or writing to the disk?
If spindownd is running but your disks aren't spinning down, the most likely reason is that a process is accessing your drive. You can check disk I/O yourself with cat /sys/block/sda/stat  (for the external USB drive use sdb). This gives something like
72965     1249  1310653   180880    23451    41251  1073528   652180        0   199840   833060

the meaning of these numbers is given in https://www.kernel.org/doc/Documentation/block/stat.txt  but if the 1st number is increasing then some process is reading the disk and if the 5th number is increasing then some process is writing to disk

Now it would be nice if there was a way to find out what process is accessing the disk, but iotop is what you need for that and I haven't had any success getting it working. 
The next best is atop (install through opt/bin/ipkg - see related post) which will show you active processes and disk activity but let's you make your own assumptions about which process is accessing the disk.

An alternative is to stop individual processes and see if the disk activity stops.

The most likely culprits are minidlna (UpnP Media server)  and mt-daapd  (iTunes server).
Check services with /sbin/service --status-all

stop MiniDlna with /etc/init.d/minidlna.init stop  (you can start it again with /etc/init.d/minidlna.init start)

stop mt-daapd with /etc/init.d/mt-daapd stop (start it again with /etc/init.d/mt-daapd start)

Another possibility is that you set up logging or a cron task that is writing to the drive. I have done that myself while testing but it's not part of the standard firmware so only you can answer that. 

3. Is the hard drive firmware preventing spin down?
The third and least likely issue is that the drive firmware itself is preventing the drive spinning down.

I don't think that is likely since hdparm is setting parameters in the drive firmware directly for example on my own drive
/sbin/hdparm -I /dev/sda | grep level   shows   Advanced power management level: 128

level 128 means the drive would never spin down itself if it didn't receive the spindown command from the goflex home spindownd program.


but if the I/O numbers are not increasing (ie no disk activity) check that the hdparm command is working with /sbin/hdparm -y /dev/sda