Extend the battery life of your (iBook) laptop


One of the aspects to solve to save the laptop’s battery is that the disk
must be spun down as long as enough time has passed without disk activity.
Usually it is difficult to make it work, especially with journaled systems
because noflush daemons don’t prevent writes in the file system journal.
I describe here some techniques to solve it, and altough I describe
in this article how to
do it in a Apple iBook with Ext3 (Debian Sid), it would be useful for any other Linux laptop.

Although you could be not interested in energy saving (is your laptop normally plugged?),
another additional advantage is that we will extend the life of the hard disk,
since the laptop’s disks are not designed to spin continuously.

This is a very fast and unchecked translation of my previous article in Spanish. Forgive me
the English mistakes, it is almost 2 am :-).

Versión en castellano

First of all, traditional daemons, like noflushd, that spin down the disks
or prevent disk writes, have almost no effectivity for
Ext3 or ReiserFS journaled filesystems
. This is due to that the operating system writes to the journal if there is any pending
write.
I was “fighting” for a long time with ext3, trying to spin the disk down playing
with different hdparm setups. I thought that it was its fault, the
disk did not stop. As in iBook the only piece in movement is the disk and
the CPU almost does not warm up, all the noise (in fact very little) and the
heat come from the disk.
In my previous configuration (until few days ago), I had disabled ext3 and
returned
back to ext2 with noflushd, because they produced a lot better results. But I don’t blame to Ext3 anymore…
it was noflushd that masked the generation of “unnecessary” logs (my
portable one is not a server:-) of syslogd and statistics of
the NTP. In addition, as my laptop is connected to my home wireless network,
which has a DHCP server in the Linux access point, whenever the IP is renegotiated,
syslogd generated several log lines (I first solved it increasing the leasing
period in the DHCP server).

Basically, we are going to do three things:

  • To indicate to the system not to store the files’ access time (noatime).
  • To prevent syslogd from storing not “interesting” log lines.
  • To prevent other programs to generate logs, specially ntpd (which does it
    with its default configuration in Debian).
  • noatime
    By default, the file systems stores in the files’ i-node the last access time.
    That means that whenever a file is read, it generates an
    write operation. If you are not interested in keeping that information
    (normally you aren’t, at least you have some tricky mail program),
    you can specify the “noatime” option in /etc/fstab for every disk file
    system (i.e. don’t do it for /proc or
    swap partitions). For example:

    # /etc/fstab: static file system information.
    #
    /dev/hda4 / ext3 defaults,noatime 0 1

    syslogd
    I prevented syslogd to generate most of uninteresting lines, like DHCP negotiations,
    bad sized packets in the wireless network, crond logs every minute, etc. Find below
    my syslogd.conf version, note that it is hardly conservative.
    You will see that the most frequent sources of logs are sent to /dev/null, for the
    others I added minus (“-“) to the begining of the filename, so syslogd doesn’t sync them
    for every line.

    # /etc/syslog.conf Configuration file for syslogd.
    #
    # For more information see syslog.conf(5)
    # manpage.

    #
    auth,authpriv.* /dev/null
    *.*;auth,authpriv.none /dev/null
    cron.* /dev/null
    daemon.* /dev/null
    *.=debug;\
    auth,authpriv.none;\
    news.none;mail.none /dev/null
    *.=info;*.=notice;*.=warn;\
    auth,authpriv.none;\
    cron,daemon.none;\
    mail,news.none /dev/null

    kern.* -/var/log/kern.log
    lpr.* -/var/log/lpr.log
    mail.* -/var/log/mail.log
    user.* -/var/log/user.log
    uucp.* -/var/log/uucp.log

    #
    # Emergencies are sent to everybody logged in.
    #
    *.emerg *

    daemon.*;mail.*;\
    news.crit;news.err;news.notice;\
    *.=debug;*.=info;\
    *.=notice;*.=warn |/dev/xconsole

    ntpd other programs
    In spite I’ve been radikal ignoring most of the logs, I still found frequent
    writes with vmstat
    . I checked every daemon, program and cron entry, and
    was surprised to discover that ntpd was the source of most writes. It was storing
    protocol statistics in /var/log/ntpstats.
    So, to avoid it, check the following lines in ntp.conf are commented out:

    #statsdir /var/log/ntpstats/

    #statistics loopstats peerstats clockstats
    #filegen loopstats file loopstats type day enable
    #filegen peerstats file peerstats type day enable
    #filegen clockstats file clockstats type day enable

    Other “dangerous” programs

    There are also other programs and daemons that generate disk writes. I
    can’t give a general recipe because it depends on your installed
    packages and configurations. Nevertheless, check the following programs:

    • exim: it generates logs every time it executes to chech the pending jobs
      in the queue. By default it executes every 15 minutes, I’ve changed it to 1 hour in
      /etc/crond.d/exim.

    • cups: it writes periodically in /var/spool/certs/.
    • modutils: modutils package comes with a script
      that is periodicallyexecuted from /etc/cron.daily/modutils,
      /sbin/insmod_ksymoops_clean which output to several files in
      /var/log/ksymoops.

    Last words
    Check the file system activity in your laptop with vmstat period,
    especially the bo columns, which shows the block outs to the
    disk.

    And, check you’ve configured the power control

    as I described in this article.
    With the configuration and packages described in both articles, your battery will last
    5 hours, or more

    Only 5 hours and 20 minutes left 🙂

    Este post ha sido traido de forma automatica desde https://web.archive.org/web/20140625063149/http:/bulma.net/body.phtml?nIdNoticia=1511 por un robot nigromante, si crees que puede mejorarse, por favor, contactanos.


    Deja una respuesta

    Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

    Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.