In Linux, a hard disk that is not used can be put to sleep. The hdparm utility modifies various hard disk settings. The option -y instantly switches the hard disk to the standby mode; the option -Y (caution) puts it to sleep. hdparm -S <x> causes the hard disk to be spun down after a certain period of inactivity. The placeholder x can be used as follows: 0 disables this mechanism, causing the hard disk to run continuously. Values from 1 to 240 are multiplied by 5 seconds. Values from 241 to 251 correspond to 1 to 11 times 30 minutes.
Often, it is not so easy to put the hard disk to sleep. In Linux, numerous processes write to the hard disk, waking it up repeatedly. Therefore, it is important to understand how Linux handles data that needs to be written to the hard disk. First, all data is buffered in the RAM. This buffer is monitored by the kernel update daemon (kupdated). When the data reaches a certain age limit or when the buffer is filled to a certain degree, the buffer content is flushed to the hard disk. The buffer size is dynamic and depends on the size of the memory and the system load. By default, kupdated is set to short intervals to achieve maximum data integrity. It checks the buffer every five seconds and notifies the bdflush daemon when data is older than thirty seconds or the buffer reaches a fill level of thirty percent. The bdflush daemon then writes the data to the hard disk. It also writes independently from kupdated if, for instance, the buffer is full. On a stable system, these settings can be modified. However, do not forget that this may have a detrimental effect on the data integrity.
|Impairment of the Data Integrity|
Changes to the kernel update daemon settings affect the data integrity. Do not touch these settings if you are not sure.
The settings for the hard disk time-out, the kupdated interval, the buffer threshold, and the age limit for data can be specified in /etc/sysconfig/powermanagement for battery operation and for AC operation. The variables are described in Section 9.2.1. “The APM Daemon (apmd)” and in the file itself. Further information is available in /usr/share/doc/packages/powersave.
Apart from these processes, journaling file systems, like ReiserFS and Ext3, write their meta data independently from bdflush, which also prevents the hard disk from spinning down. To avoid this, a special kernel extension has been developed for mobile devices. See /usr/src/linux/Documentation/laptop-mode.txt for details.
Another important factor is the way active programs behave. For example, good editors regularly write hidden backups of the currently modified file to the hard disk, causing the disk to wake up. Features like this can be disabled at the expense of data integrity.
In this connection, the mail daemon postfix makes use of the variable POSTFIX_LAPTOP. If this variable is set to yes, postfix will access the hard disk far less frequently. However, this is irrelevant if the interval for kupdated was increased.