Linux – Make a hard disk sleep and only wake up when needed

hard drivelinux

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?

Best Answer

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.

Related Topic