Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Im looking for some small script or application which could log the time when a non-system disk wakes up.

I cannot identify which application or script wakes up my non-system drive (which has to be asleep until I work with it). I have already set the noatime flag, tried to use powertop and iotop to determine which application could prevent it from going to sleep - but with no result.

So my plan is to set this drive asleep (hdparm -Y) and see at what time it gets regularly woken up.

Thanks for any advice.

share|improve this question

5 Answers 5

up vote 1 down vote accepted

In order to find out what files are being accessed (which may help narrow down the process responsible), you can try using inotifywatch which can be set up to recursively watch directories below a directory you choose. Be sure to read the warnings in the man page regarding using --recursive on a large tree.

When a filesystem event occurs in a directory in that tree, it is recorded and output in a table. You can use --timeout to limit the amount of time that the watch is active.

If the results are consistent, you can run a non-recursive watch on the files in that directory to narrow down the particular file.

share|improve this answer

I can't answer to your question but I want to point on you on a detail that might be interesting: several sata hdd have a jumper to set them sleeping by default (the controller has to send a sata command to wake up the disk. [not all controllers can do that]).

Is the jumper already set?

Dam

share|improve this answer
    
I looked into the manual for Seagate drives, but it appears to have only one possible jumper configuration and that's to limit the drive's operation to 1.5Gbps. –  NumberFour Nov 20 '10 at 13:54
    
what's the model and sn# of the disk? –  damko Nov 20 '10 at 17:00
    
Barracuda,3QD0CGGM –  NumberFour Nov 21 '10 at 11:32
    
mmm can't find anything helpfull about the spin-down of that disk. Sorry –  damko Nov 21 '10 at 13:29

You can use hdparm -C to get the power mode status of the disk at any time. Here's a script that would give you the times:

while true; do 
  state=`hdparm -C /dev/sda|grep "^ drive"|cut -c 19-`
  echo `date` $state
  sleep 1
done

Run the script with sudo, as hdparm needs root privileges. You can redirect echo to some file, e.g.:

echo `date` $state >> /tmp/sda_state

and of course change the disk you are monitoring (I used /dev/sda) to what you want and the sleep interval, such as sleep 120 to query every two minutes.

This doesn't give you the process which wakes up the drive, though.

You may have issues with the above due to some bugs:

If you are having issues with hdparm -C waking up your drive, try this instead:

smartctl -i -n standby /dev/sda|grep "^Power mode"

As per man smartctl, when run with -n standby, smartctl should not wake up the drive. Note there are also bugs with this:

so try to see if it works.

share|improve this answer
    
hdparm -C wakes up the drive as well –  NumberFour Nov 21 '10 at 0:05
    
I edited to provide an alternative - hope this is going to work for you. –  icyrock.com Nov 21 '10 at 1:55
    
Unfortunately the drive still wakes up, I even tried the new version of smartmontools 5.40 but with no result :( Anyway thanks for your advice! –  NumberFour Nov 21 '10 at 11:46
    
Try trying the latest version of hdparm also. Sorry it didn't work out for you, but it very well might be an issue with the hardware. If you can, try it on some other machine and/or a different OS. –  icyrock.com Nov 21 '10 at 15:26

See this ubuntu bug report on how to track that down (and a possible cause).

Short answers: auditctl -w /dev/sdX -p rwa and udisks

share|improve this answer

As you are on linux, you can use the new fatrace utility, which logs every file access and tells you which process is responsible:

https://launchpad.net/fatrace

More information here:

http://www.piware.de/2012/02/fatrace-report-system-wide-file-access-events/

It makes use of the linux fanotify API (more details) available since linux kernel 2.6.37.

fatrace isn't packaged by most distributions as of July 2014 (it entered debian testing recently, so should ship in 'jessie'), but is easy to install from source.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.