KDE Energiesparmodi optimieren

In meinem letzten Beitrag habe ich erwähnt, dass mein Notebook im Batteriebetrieb unter Linux / KDE deutlich mehr Strom frisst als unter Windows 7. Zwar habe ich als Hauptursache die zugeschaltete diskrete Grafikkarte ausgemacht (und behoben); Dennoch habe ich durch etwas Recherche zahlreiche Optimierungsmöglichkeiten gefunden.

Diese habe ich in ein Script nach /usr/local/sbin/powersave.sh gepackt und einen entsprechenden Eintrag in sudoers hinzugefügt, da die Einstellungen Root-Rechte benötigen. Anschließend konnte ich per sudo das Script ohne Eingabe des Root-Passworts ausführen, was es mir ermöglichte, das Script auch vom KDE Energie-Manager Powerdevil ausführen zu lassen. Hierzu habe ich in den Einstellungen der Energieverwaltung in den Details des Powersave Profils folgenden Aufruf in das Feld für ein benutzerdefiniertes Script eingetragen:
sudo /usr/local/sbin/powersave.sh

Dies bewirkt, dass KDE nun die im Script hinterlegten Optimierungen automatisch ausführt, wenn das Notebook ins Powersave Profil wechselt.

Analog hierzu habe ich auch ein max_performance.sh Script erstellt, welches alle vom Powersave-Script vorgenommenen Änderungen wieder rückgängig macht. Dieses Script hat auch einen Eintrag in sudoers erhalten und wird dank Powerdevil nun beim Aufruf des Performance Profils ausgeführt.

Untenstehend findet Ihr meine beiden Scripte. Beachtet bitte, dass für Eure Notebooks ziemlich sicher Anpassungen notwendig sein werden. Vor allem, wenn ihr keine hybride ATI Grafikkarte oder keine CPU mit 4 Kernen habt.


 
 
 

15 Kommentare zu “KDE Energiesparmodi optimieren”


  1. rakhmad
    21. Juli 2010 um 12:28

    after using those scripts, how does linux perform compare to windows 7? and which process consume most power?

  2. Andreas Demmer
    21. Juli 2010 um 12:36

    Now Linux consumes about 15W with low display brightness, deactivated display effects and enabled wireless. Windows 7 consumes about 13W with display effects. But this is pretty close, now.

    Most wakeups are caused by the i915 (graphics) and the wl (wireless) drivers. I read that the i915 has a bug in wakeups that can be worked around by deactivating DRI in xorg.conf. This should save some more watts. BUT it disables desktop effects permanently what makes me not doing this.

  3. Thorsten
    21. Juli 2010 um 14:51

    Thank you for the scripts, Andreas. Though I wonder why powerdevil doesn’t do all these things… :-(

  4. Ryan
    21. Juli 2010 um 15:52

    You should separate this into a series of script in /etc/pm/power.d/. That way, these settings would not depend on you having powerdevil running at the time. So they would work even if you’re not logged in, or logged in at the console for some reason.

    For example, /etc/pm/power.d/cpu-frequency-scaling:

    #!/bin/sh

    if [ "$1" = true ]; then
    GOVERNOR=”powersave”
    else
    GOVERNOR=”ondemand”
    fi

    for x in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
    echo “$GOVERNOR” > “$x”
    done

  5. Fri13
    21. Juli 2010 um 17:17

    Very nice post about powermanagement. Even the sudoers file editing is not needed (the top post), it was nice trick (perhaps even a hack?) to get wanted thing. Hopefully more people would know what to do with the sudo (even it is not so good for security, it makes things easier).

  6. drf
    21. Juli 2010 um 20:12

    @Thorsten: well, it actually does all of these things: that’s why I put the script feature in the first place. No other powermanager allows you to do such a thing.

    Btw, if you meant “by default”, the answer is: it will never do. These are quite hard powersaving settings which surely fit a lot of use cases, but IMHO are not suitable for a good default.

    Although, I might consider to install those scripts along with PowerDevil – that is surely possible.

    @Andreas: nice stuff, I’ll have to try them :)

  7. Freddie
    21. Juli 2010 um 20:21

    Why two separate scripts? Why not one script with a case or if statement at the top? Or even mixed into the body? Seems like a waste to have two separate scripts that do the same thing, just in reverse.

    Then you just pass in a parameter (fast/slow; or powersave/ondemand) on the command-line.

  8. Obi-Wahn
    21. Juli 2010 um 21:01

    Danke für das Skript. Ich habe seit ein paar Monaten einen Asus UL50VT, der schon sehnsüchtig auf ein Linux wartet. Ich wollte in den nächsten paar Tagen openSUSE 11.3 installieren und dann mal gucken, ob ich dein Skript bei mir anpassen kann. Es gibt für mich aber auch noch andere Möglichkeiten: https://launchpad.net/~asus-ul30

  9. michael
    22. Juli 2010 um 09:47

    hello, noob question here. What exactly do I need to put in sudoers to let the scripts work?

    I have a script of mine which i’d like to run, but if i put it in powerdevil it dooesn’t start and I need to start it manually every time.

    Now I understand why it doesn’t work, but could someone please tell me what I need to add to sudoers?

    Ty.

  10. Andreas Demmer
    22. Juli 2010 um 09:53

    First make your script executable. Then add it to sudoers with visudo (to not mess it up and break your installation). Add this line for each script:
    your_username ALL = NOPASSWD: /path/to/your/script.sh

    After this, you are able to excute “sudo /path/to/your/script.sh” without having to enter the root password.

    Be sure that this script is only writable for you and root to avoid security holes!

  11. michael
    22. Juli 2010 um 10:38

    many many thanks :)

  12. warnec
    22. Juli 2010 um 13:31

    For noobs, it’s best to try something like EDITOR=nano visudo so that they don’t get lost with vi ;)

    PS How is the energy draw with compositing on?

  13. warnec
    22. Juli 2010 um 13:33

    PPS are these tricks:

    powersave:

    #
    #
    # put HDDs to min_power mode
    #
    echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
    #
    echo min_power > /sys/class/scsi_host/host1/link_power_management_policy
    #

    #
    # advice HDD to sleep after 5min idle
    #
    /sbin/hdparm -B 1 -S 60 /dev/sda
    #

    #
    # increase write cache time to 15s
    #
    echo 1500 > /proc/sys/vm/dirty_writeback_centisecs

    max perf.:
    #
    #
    # put HDDs to max_performance mode
    #
    echo max_performance > /sys/class/scsi_host/host0/link_power_management_policy
    #
    echo max_performance > /sys/class/scsi_host/host1/link_power_management_policy
    #

    #
    # advice HDD to sleep after 60min
    #
    /sbin/hdparm -B 254 -S 242 /dev/sda
    #

    #
    # decrease write cache time
    #
    echo 500 > /proc/sys/vm/dirty_writeback_centisecs

    of any use for SSD?

  14. Andreas Demmer
    26. Juli 2010 um 09:18

    WARNING: I forgot to enable the DVD-drive polling when plugged again, resulting in the DVD drive not recognizing media automatically. To fix this, add the following call to the max_performance script:
    hal-disable-polling –enable-polling –device /dev/cdrom

  15. Elaina Zelenka
    29. Juli 2010 um 22:25

    Hey there’s one bug with the site on OPera the sidebar is weird :/

Kommentar abgeben: