Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to connect another hard disk to my computer, which I want to sleep 99% of the time. I will only use it for a few things, but I need it to be mounted at all times.

To achieve this I would like to know:

  1. How do I log which processes accesses a device? I need the logging to be able to tell what is causing the hard disk to wake up if it does, so I may act on it.
  2. Are there any special kernel settings I need to make so that the device may sleep longer?
  3. How do I set the sleep intervals of the hard disk?
share|improve this question

Sleep interval is called "APM" (Automatic Power Management) and spindown_time. This is controlled with hdparm like this:

hdparm -B 50 -S 36 /dev/disk/by-label/BACKUP-HDD

It will make your HDD to spindown on ~3min inactivity.

share|improve this answer - fuser is a UNIX command used to show which processes are using a specified file, file system, or socket. - get/set ATA/SATA drive parameters under Linux (look for -S option) - The sg3_utils package contains utilities that send SCSI commands to devices. As well as devices on transports traditionally associated with SCSI (look for sg_start)

share|improve this answer
Thanks for your informative answer! It looks like fuser only tells me which processes are using a file, filesystem och socket at the instance of issuing the command. While this is very useful if a process does something quick, like list the contents of the device root directory, I might miss it even if I have fuser running in a loop. If there were something which would wait and log all activity until I tell it to stop, it would be even more helpful in this situation. Do you know of any? – Deleted Dec 13 '09 at 11:12
I guess hdparam is what i'll use to setup wait time before sleeping? And the sg3_utils is just a powerful tool but I won't use it in this case? (As I guess I won't have to specifying manually when the HDD should sleep after setting it up using hdparam?) – Deleted Dec 13 '09 at 11:13

btrace or blktrace (a wrapper of btrace) track kernel block I/O and can help you there.

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:

More information here:

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

fatrace isn't packaged by all 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
I don't know what you mean by "most" distributions. As usual Debian is the last distro to get something. I have had it available on Fedora for quite some time... – Michael Hampton Jul 28 '14 at 11:19

lsof +D /path/to/mount should show you every process which has any opened file in the path indicated.

share|improve this answer

Your Answer


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.