Strategies for Reducing Spin-ups

Now that we have some idea of how I/O works, we can think about how to avoid spinning up the disk.

If you have multiple disks, and only need to keep some of them spun down, you could try and place the directories on the disks so as to minimize the frequency with which you access the disks that you want to keep spun down. I will not say more about that approach, other than to say that the kernel patch in the Section called Hunting for Sources of I/O might help you partition the data across drives by telling you which processes are spinning up the disk.

Instead, we will consider the case where we only have one disk. What we want to do is to use the buffering ability of the kernel to reduce the need to spin up the disk. We will do so in three ways:

  1. To avoid spinning up the disk for reads, we will load files that we know we need into the buffer cache before spinning down the disk.

  2. To avoid spinning up the disk for writes, we will use noflushd to alter the behavior of kupdate. More details later.

  3. We will try to reduce the number of synchronous writes, as they also trigger disk spin-ups.

Warning

The second and third approaches mean that we keep dirty buffers around longer before updating the disk. This includes modified files that you have saved from any applications you are using. If the system crashes, you lose all the data in dirty buffers. The net result is that you are likely to lose much more data on a crash than you do in a default configuration. Think minutes or hours worth instead of seconds worth. You can always flush the buffers manually, using the sync command. This will, of course, spin up the disk.

The first and third approaches require some detective work to figure out what processes are reading data, and which processes are writing synchronously. We'll talk about how to figure that out later. First, we'll look at noflushd.