Saving 2 W power by Making Sure Laptop_Mode oesn't destroy your HD

Laptop_mode is actually a great thing, as it activates a few powerful power saving modes in Linux, most importantly disk power saving and delayed writes. But if you use it with out of the box settings, there are two major bugs in Laptop Mode Tools, which could cause your disk to crash and are the reason it's normally disabled. Now let me show you how to work around them and easily save 2 W of power:

1. Hard disks don't obey the hdparm -S setting. The spindown timeout is often not regarded by the hard disks, but only the general power management setting in -B. The problem is that laptop_mode automatically sets this setting to 1. This means hard disks will spin down very quicky and very often. This will wear out and destroy your disk. So make sure you adjust the BATT_HD_POWERMGMT to 130 or so.

2. Every program can spin up your disk with an fsync call. The whole sense of laptop_mode and the corresponding kernel tweaks is that the disk doesn't spin up for writes more often than every X minutes. This is why you should make sure you disable the fsync call. The problem is currently a kernel patch is needed for this. The good thing is that I've already created and posted it here on my blog.
With the patch applied your disk will only spin up every X minutes as set by the hdparm -B setting or when it has to read new data. With this patch you also avoid having to reset all your deamons, esp. syslog, and other software, esp. browsers, to power friendly values. They can fsync all they want but it won't spin up the disk. And in my experience it's much more likely that the software crashes, in which case the data is still in the kernel write buffer, so not lost. Of course if the whole system crashes you will lose some minutes of data unless you manage to Reisub your way out of it.

After you have everything set up, ensure it's working fine with: watch " sudo smartctl --all /dev/sda | grep Load_Cycle" to ensure it's not increasing too much.

Then you can lean back, relax and enjoy easily 2 W less power usage. Without either of them you risk damage to your disk. In any case, enable SMART and regularly check the values.

3 comments:

  1. "This is why you should make sure you disable the fsync call."

    I see. Fixing the desktop environments and applications to not to thrash hard drive is not even considered.

    As much as I love Linux, it still very far from being a laptop friendly OS. Wasn't gouging it against Windows, but on the same hardware Mac OS was managing 4+ hours, while Ubuntu (and Xubuntu) less than 2 hours - load being reading a PDF and listening some mp3s. Quite miserable.

    ReplyDelete
  2. Well what you suggest is that applications should check whether they are run from battery or not and then not use f sync? And that would have to be done for each and every one.doesn't it make more sense to fix out all at One place and make laptop-mode work as it should?

    ReplyDelete
  3. Ps
    I think your problem is probably driver related, try a system with good power support in linux and it will be the opposite: my netbook makes it 30% longer in linux.

    ReplyDelete

I appreciate comments. And I do read them.