Сборник статей Handbook inside ! : Linux не для идиотов inside ! : Версия 1 от 15. 07. 2007 2007

Pdf просмотр
Размер5.65 Mb.
ТипСборник статей
1   ...   19   20   21   22   23   24   25   26   ...   50
4. LCD Power Management
As you can see in figure 1.1, the LCD display consumes the biggest part of energy (might not be the case for non-mobile CPU's). Thus it's quite important not only to shut the display off when not needed, but also to reduce it's backlight if possible. Most laptops offer the possibility to control the backlight dimming.
Standby settings
The first thing to check is the standby/suspend/off timings of the display. As this depends heavily on your windowmanager, I'll let you figure it out yourself. Just two common places:
Blanking the terminal can be done with setterm -blank , setterm
-powersave on and setterm -powerdown . For X.org, modify
/etc/X11/xorg.conf similar to this:
Code Listing 4.1: LCD suspend settings in X.org and XFree86
Section "ServerLayout"
Identifier [...]
Option "BlankTime" "5" # Blank the screen after 5 minutes (Fake)
Option "StandbyTime" "10" # Turn off screen after 10 minutes (DPMS)
Option "SuspendTime" "20" # Full suspend after 20 minutes
Option "OffTime" "30" # Turn off after half an hour
Section "Monitor"
Identifier [...]
Option "DPMS" "true"
This is the same for XFree86 and /etc/X11/XF86Config.
Backlight dimming
Probably more important is the backlight dimming. If you have access to the dimming settings via a tool, write a small script that dims the backlight in battery mode and place it in your battery runlevel. The following script should work on most IBM Thinkpads and
Toshiba laptops. You've got to enable the appropriate option in your kernel (IBM
Thinkpads only). For Toshiba laptops, install app-laptop/acpitool and skip configuration of ibm_acpi as described below.
Warning: Support for setting brightness is marked experimental in ibm-acpi. It accesses hardware directly and may cause severe harm to your system. Please read the ibm-acpi website

To be able to set the brightness level, the ibm_acpi module has to be loaded with the experimental parameter.
Code Listing 4.2: automatically loading the ibm_acpi module
(Please read the warnings above before doing this!)
# echo "options ibm_acpi experimental=1" >> /etc/modules.d/ibm_acpi
# /sbin/modules-update
# echo ibm_acpi >> /etc/modules.autoload.d/kernel-2.6
# modprobe ibm_acpi
This should work without error messages and a file /proc/acpi/ibm/brightness should be created after loading the module. An init script will take care of choosing the brightness according to the power source.
Code Listing 4.3: /etc/conf.d/lcd-brightness
# See /proc/acpi/ibm/brightness for available values
# Please read /usr/src/linux/Documentation/ibm-acpi.txt
# brigthness level in ac mode. Default is 7.
# brightness level in battery mode. Default is 4.
Code Listing 4.4: /etc/init.d/lcd-brightness
#!/sbin/runscript set_brightness() {
if on_ac_power then
fi if [ -f /proc/acpi/ibm/brightness ]
then ebegin "Setting LCD brightness"
echo "level ${LEVEL}" > /proc/acpi/ibm/brightness eend $?
elif [[ -e /usr/bin/acpitool && -n $(acpitool -T | grep "LCD brightness") ]]
then ebegin "Setting LCD brightness"
acpitool -l $LEVEL >/dev/null || ewarn "Unable to set lcd brightness"
eend $?
else ewarn "Setting LCD brightness is not supported."
ewarn "For IBM Thinkpads, check that ibm_acpi is loaded into the kernel"
ewarn "For Toshiba laptops, you've got to install app-laptop/acpitool"
start() {
stop () {
When done, make sure brightness is adjusted automatically by adding it to the battery runlevel.
Code Listing 4.5: Enabling automatic brightness adjustment
# chmod +x /etc/init.d/lcd-brightness
# rc-update add lcd-brightness battery
# rc
5. Disk Power Management
Hard disks consume less energy in sleep mode. Therefore it makes sense to activate power saving features whenever the hard disk is not used for a certain amount of time. I'll show you two alternative possibilities to do it. First, laptop-mode will save most energy due to several measures which prevent or at least delay write accesses. The drawback is that due to the delayed write accesses a power outage or kernel crash will be more dangerous for data loss. If you don't like this, you have to make sure that there are no processes which write to your hard disk frequently. Afterwards you can enable power saving features of your hard disk with hdparm as the second alternative.
Increasing idle time - laptop-mode
Recent kernels (2.6.6 and greater, recent 2.4 ones and others with patches) include the so-called laptop-mode. When activated, dirty buffers are written to disk on read calls or after 10 minutes (instead of 30 seconds). This minimizes the time the hard disk needs to be spun up.
Code Listing 5.1: Automated start of laptop-mode
# emerge laptop-mode-tools laptop-mode-tools has its configuration file in /etc/laptop-mode/laptop-mode.conf. Adjust it the way you like it, it's well commented. Run rc-update add laptop_mode battery to start it automatically.
Recent versions (1.11 and later) of laptop-mode-tools include a new tool lm-profiler. It will monitor your system's disk usage and running network services and suggests to disable unneeded ones. You can either disable them through laptop-mode-tools builtin runlevel support (which will be reverted by Gentoo's /sbin/rc) or use your default/battery runlevels
Code Listing 5.2: Sample output from running lm-profiler

# lm-profiler
Profiling session started.
Time remaining: 600 seconds
[4296896.602000] amarokapp
Time remaining: 599 seconds
[4296897.714000] sort
[4296897.970000] mv
Time remaining: 598 seconds
Time remaining: 597 seconds
[4296900.482000] reiserfs/0
After profiling your system for ten minutes, lm-profiler will present a list of services which might have caused disk accesses during that time.
Code Listing 5.3: lm-profiler suggests to disable some services
Program: "atd"
Reason: standard recommendation (program may not be running)
Init script: /etc/init.d/atd (GUESSED)
Do you want to disable this service in battery mode? [y/N]: n
To disable atd as suggested in the example above, you would run rc-update del atd battery. Be careful not to disable services that are needed for your system to run properly - lm-profiler is likely to generate some false positives. Do not disable a service if you are unsure whether it's needed.
Limiting Write Accesses
If you don't want to use laptop-mode, you must take special care to disable services that write to your disk frequently - syslogd is a good candidate, for example. You probably don't want to shut it down completely, but it's possible to modify the config file so that
"unnecessary" things don't get logged and thus don't create disk traffic. Cups writes to disk periodically, so consider shutting it down and only enable it manually when needed.
Code Listing 5.4: Disabling cups in battery mode
# rc-update del cupsd battery
You can also use lm-profiler from laptop-mode-tools (see above) to find services to disable. Once you eliminated all of them, go on with configuring hdparm. hdparm
The second possibility is using a small script and hdparm. Skip this if you are using laptop- mode. Otherwise, create /etc/init.d/pmg_hda:
Code Listing 5.5: Using hdparm for disk standby
#!/sbin/runscript depend() {
after hdparm
start() {
ebegin "Activating Power Management for Hard Drives"
hdparm -q -S12 /dev/hda eend $?
stop () {
ebegin "Deactivating Power Management for Hard Drives"
hdparm -q -S253 /dev/hda eend $?
See man hdparm for the options. If your script is ready, add it to the battery runlevel.
Code Listing 5.6: Automate disk standby settings
# chmod +x /etc/init.d/pmg_hda
# /sbin/depscan.sh
# rc-update add pmg_hda battery
Important: Be careful with sleep/spin down settings of your hard drive. Setting it to small values might wear out your drive and lose warranty.
Other tricks
Another possibility is to deactivate swap in battery mode. Before writing a swapon/swapoff switcher, make sure there is enough RAM and swap isn't used heavily, otherwise you'll be in big problems.
If you don't want to use laptop-mode, it's still possible to minimize disk access by mounting certain directories as tmpfs - write accesses are not stored on a disk, but in main memory and get lost with unmounting. Often it's useful to mount /tmp like this - you don't have to pay special attention as it gets cleared on every reboot regardless whether it was mounted on disk or in RAM. Just make sure you have enough RAM and no program (like a download client or compress utility) needs extraordinary much space in /tmp. To activate this, enable tmpfs support in your kernel and add a line to /etc/fstab like this:
Code Listing 5.7: Editing /etc/fstab to make /tmp even more volatile none /tmp tmpfs size=32m 0 0
Warning: Pay attention to the size parameter and modify it for your system. If you're unsure, don't try this at all, it can become a performance bottleneck easily. In case you want to mount /var/log like this, make sure to merge the log files to disk before unmounting. They are essential. Don't attempt to mount /var/tmp like this. Portage uses it for compiling...
6. Power Management For Other Devices
Graphics Cards

In case you own an ATI graphics card supporting PowerPlay (dynamic clock scaling for the the graphics processing unit GPU), you can activate this feature in X.org. Open
/etc/X11/xorg.conf and add (or enable) the DynamicClocks option in the Device section.
Please notice that this feature will lead to crashes on some systems.
Code Listing 6.1: Enabling ATI PowerPlay support in X.org
Section "Device"
Option "DynamicClocks" "on"
Wireless Power Management
Wireless LAN cards consume quite a bit of energy. Put them in Power Management mode in analogy to the pmg_hda script.
Note: This script assumes your wireless interface is called wlan0; replace this with the actual name of your interface.
Code Listing 6.2: WLAN Power Management automated
#!/sbin/runscript start() {
ebegin "Activating Power Management for Wireless LAN"
iwconfig wlan0 power on eend $?
stop () {
ebegin "Deactivating Power Management for Wireless LAN"
iwconfig wlan0 power off eend $?
Starting this script will activate power saving features for wlan0. Save it as
/etc/init.d/pmg_wlan0 and add it to the battery runlevel like the disk script above. See man iwconfig for details and more options like the period between wakeups or timeout settings.
If your driver and access point support changing the beacon time, this is a good starting point to save even more energy.
Code Listing 6.3: Power Management for WLAN
# chmod +x /etc/init.d/pmg_wlan0
# /sbin/depscan.sh
# rc-update add pmg_wlan0 battery
USB Power Management
There are two problems with USB devices regarding energy consumption: First, devices like USB mice, digital cameras or USB sticks consume energy while plugged in. You cannot avoid this (nevertheless remove them in case they're not needed). Second, when there are USB devices plugged in, the USB host controller periodically accesses the bus
which in turn prevents the CPU from going into sleep mode. The kernel offers an experimental option to enable suspension of USB devices through driver calls or one of the power/state files in /sys.
Code Listing 6.4: Enabling USB suspend support in the kernel
Device Drivers
USB support
[*] Support for Host-side USB
[*] USB suspend/resume (EXPERIMENTAL)
7. Sleep States: sleep, standby, and suspend to disk
ACPI defines different sleep states. The more important ones are
S1 aka Standby
S3 aka Suspend to RAM aka Sleep
S4 aka Suspend to Disk aka Hibernate
They can be called whenever the system is not in use, but a shutdown is not wanted due to the long boot time.
Sleep (S3)
The ACPI support for these sleep states is marked experimental for good reason. APM sleep states seem to be more stable, however you can't use APM and ACPI together.
Code Listing 7.1: Kernel configuration for the various suspend types
Power Management Options --->
[*] Power Management support
ACPI (Advanced Configuration and Power Interface) Support --->
[*] ACPI Support
[*] Sleep States
Once your kernel is properly configured, you can use the hibernate-script to activate suspend or sleep mode. Let's install that first.
Code Listing 7.2: Installing the hibernate-script
# emerge hibernate-script
Some configuration has to be done in /etc/hibernate The default package introduces two configuration files hibernate.conf and ram.conf.
To configure sleep, edit ram.conf in /etc/hibernate. UseSysfsPowerState mem is already setup correctly, but you have to go through the rest of the configuration file and set it up for your system. The comments and option names will guide you. If you use nfs or samba shares over the network, make sure to shutdown the appropriate init scripts to avoid timeouts.
Ready? Now is the last chance to backup any data you want to keep after executing the next command. Notice that you probably have to hit a special key like Fn to resume from
Code Listing 7.3: Calling sleep
# hibernate-ram
If you're still reading, it seems to work. You can also setup standby (S1) in a similar way by copying ram.conf to standby.conf and creating a symlink /usr/sbin/hibernate-standby pointing to /usr/sbin/hibernate. S3 and S4 are the more interesting sleep states due to greater energy savings however.
Hibernate (S4)
This section introduces hibernation, where a snapshot of the running system is written to disk before powering off. On resume, the snapshot is loaded and you can go on working at exactly the point you called hibernate before.
Warning: Don't exchange non hot-pluggable hardware when suspended. Don't attempt to load a snapshot with a different kernel image than the one it was created with. Shutdown any NFS or samba server/client before hibernating.
There are two different implementations for S4. The original one is swsusp, then there is the newer suspend2 with a nicer interface (including fbsplash support). A feature comparison is available at the suspend2 Homepage. There used to be Suspend-to-Disk
(pmdisk), a fork of swsusp, but it has been merged back.
Suspend2 is not included in the mainline kernel yet, therefore you either have to patch your kernel sources with the patches provided by suspend2.net or use sys- kernel/suspend2-sources.
The kernel part for both swusp and suspend2 is as follows:
Code Listing 7.4: Kernel configuration for the various suspend types
Power Management Options --->
(hibernate with swsusp)
[*] Software Suspend
(replace /dev/SWAP with your swap partition)
(/dev/SWAP) Default resume partition
(hibernate with suspend2)
Software Suspend 2
--- Image Storage (you need at least one writer)
[*] File Writer
[*] Swap Writer
--- General Options
[*] LZF image compression
(replace /dev/SWAP with your swap partition)
(swap:/dev/SWAP) Default resume device name
[ ] Allow Keep Image Mode
The configuration for swsusp is rather easy. If you didn't store the location of your swap partition in the kernel config, you can also pass it as a parameter with the resume=/dev/SWAP directive. If booting is not possible due to a broken image, use the
noresume kernel parameter. The hibernate-cleanup init script invalidates swsusp images during the boot process.
Code Listing 7.5: Invalidating swsusp images during the boot process
# rc-update add hibernate-cleanup boot
To activate hibernate with swsusp, use the hibernate script and set UseSysfsPowerState disk in /etc/hibernate/hibernate.conf.
Warning: Backup your data before doing this. Run sync before executing one of the commands to have cached data written to disk. First try it outside of X, then with X running, but not logged in.
If you experience kernel panics due to uhci or similar, try to compile USB support as module and unload the modules before sending your laptop to sleep mode. There are configuration options for this in hibernate.conf
Code Listing 7.6: Hibernating with swsusp
# nano -w /etc/hibernate.conf
(Make sure you have a backup of your data)
# hibernate
The following section discusses the setup of suspend2 including fbsplash support for a nice graphical progress bar during suspend and resume.
The first part of the configuration is similar to the configuration of swsusp. In case you didn't store the location of your swap partition in the kernel config, you have to pass it as a kernel parameter with the resume2=swap:/dev/SWAP directive. If booting is not possible due to a broken image, append the noresume2 parameter. Additionally, the hibernate- cleanup init script invalidates suspend2 images during the boot process.
Code Listing 7.7: Invalidating suspend2 images during the boot process
# rc-update add hibernate-cleanup boot
Now edit /etc/hibernate/hibernate.conf, enable the suspend2 section and comment everything in the sysfs_power_state and acpi_sleep sections. Do not enable the fbsplash part in global options yet.
Code Listing 7.8: Hibernating with suspend2
# nano -w /etc/hibernate.conf
(Make sure you have a backup of your data)
# hibernate
Please configure fbsplash now if you didn't do already. To enable fbsplash support during hibernation, the sys-apps/suspend2-userui package is needed. Additionally, you've got to enable the fbsplash USE flag.
Code Listing 7.9: Installing suspend2-userui
# mkdir -p /etc/portage
# echo "sys-apps/suspend2-userui fbsplash" >> /etc/portage/package.use

# emerge suspend2-userui
The ebuild tells you to make a symlink to the theme you want to use. For example, to use the livecd-2005.1 theme, run the following command:
Code Listing 7.10: Using the livecd-2005.1 theme during hibernation
# ln -sfn /etc/splash/livecd-2005.1 /etc/splash/suspend2
If you don't want a black screen in the first part of the resume process, you have to add the suspend2ui_fbsplash tool to your initrd image. Assuming you created the initrd image with splash_geninitramfs and saved it as /boot/fbsplash-emergence-1024x768, here's how to do that.
Code Listing 7.11: Adding suspend2ui_fbsplash to an initrd image
# mount /boot
# mkdir
# cp /boot/fbsplash-emergence-1024x768
# cd
# gunzip -c fbsplash-emergence-1024x768 | cpio -idm --quiet -H newc
# rm fbsplash-emergence-1024x768
# cp /usr/sbin/suspend2ui_fbsplash sbin/
# find . | cpio --quiet --dereference -o -H newc | gzip -9 > /boot/fbsplash-suspend2- emergence-1024x768
Afterwards adjust grub.conf respectively lilo.conf so that your suspend2 kernel uses
/boot/fbsplash-suspend2-emergence-1024x768 as initrd image. You can now test a dry run to see if everything is setup correctly.
Code Listing 7.12: Test run for fbsplash hibernation
# suspend2ui_fbsplash -t
Afterwards open /etc/hibernate/hibernate.conf again and activate the fbsplash options.
Execute hibernate and enjoy.
8. Troubleshooting
Q: I'm trying to change the CPU frequency, but
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor does not exist.
A: Make sure your processor supports CPU frequency scaling and you chose the right
CPUFreq driver for your processor. Here is a list of processors that are supported by cpufreq (kernel 2.6.7): ARM Integrator, ARM-SA1100, ARM-SA1110, AMD Elan - SC400,
SC410, AMD mobile K6-2+, AMD mobile K6-3+, AMD mobile Duron, AMD mobile Athlon,
AMD Opteron, AMD Athlon 64, Cyrix Media GXm, Intel mobile PIII and Intel mobile PIII-M on certain chipsets, Intel Pentium 4, Intel Xeon, Intel Pentium M (Centrino), National
Semiconductors Geode GX, Transmeta Crusoe, VIA Cyrix 3 / C3, UltraSPARC-III, SuperH
SH-3, SH-4, several "PowerBook" and "iBook2" and various processors on some ACPI

2.0-compatible systems (only if "ACPI Processor Performance States" are available to the
ACPI/BIOS interface).
Q: My laptop supports frequency scaling, but /sys/devices/system/cpu/cpu0/cpufreq/ is empty.
A: Look for ACPI related error messages with dmesg | grep ACPI. Try to update the BIOS, especially if a broken DSDT is reported. You can also try to fix it yourself (which is beyond the scope of this guide).
Q: My laptop supports frequency scaling, but according to /proc/cpuinfo the speed never changes.
A: Probably you have activated symmetric multiprocessing support (CONFIG_SMP) in your kernel. Deactivate it and it should work. Some older kernels had a bug causing this.
In that case, run emerge x86info, update your kernel as asked and check the current frequency with x86info -mhz.
Q: I can change the CPU frequency, but the range is not as wide as in another OS.
A: You can combine frequency scaling with ACPI throttling to get a lower minimum frequency. Notice that throttling doesn't save much energy and is mainly used for thermal management (keeping your laptop cool and quiet). You can read the current throttling state with cat /proc/acpi/processor/CPU/throttling and change it with echo -n "0:x" >
/proc/acpi/processor/CPU/limit, where x is one of the Tx states listed in
Q: When configuring the kernel, powersave, performance and userspace governors show up, but that ondemand thing is missing. Where do I get it?
A: The ondemand governor is only included in recent kernel sources. Try updating them.
Q: Battery life time seems to be worse than before.
A: Check your BIOS settings. Maybe you forgot to re-enable some of the settings.
Q: My battery is charged, but KDE reports there would be 0% left and immediately shuts down.
A: Check that battery support is compiled into your kernel. If you use it as a module, make sure the module is loaded.
Q: My system logger reports things like "logger: ACPI group battery / action battery is not defined".
A: This message is generated by the /etc/acpi/default.sh script that is shipped with acpid.
You can safely ignore it. If you like to get rid of it, you can comment the appropriate line in
/etc/acpi/default.sh as shown below:
Code Listing 8.1: Disabling warnings about unknown acpi events
*) # logger "ACPI action $action is not defined"
Q: I have a Dell Inspiron 51XX and I don't get any ACPI events.

A: This seems to be a kernel bug. Read on here.
Q: I activated the DynamicClocks option in xorg.conf and now X.org crashes / the screen stays black / my laptop doesn't shutdown properly.
A: This happens on some systems. You have to disable DynamicClocks.
Q: I want to use suspend2, but it tells me my swap partition is too small. Resizing is not an option.
A: If there is enough free space on your system, you can use the filewriter instead of the swapwriter. The hibernate-script supports it as well. More information can be found in
Q: I just bought a brand new battery, but it only lasts for some minutes! What am I doing wrong?
A: First follow your manufacturer's advice on how to charge the battery correctly.
Q: The above didn't help. What should I do then?
A: Some batteries sold as "new" are in fact old ones. Try the following:
Code Listing 8.2: Querying battery state
$ grep capacity /proc/acpi/battery/BAT0/info design capacity: 47520 mWh last full capacity: 41830 mWh
If the "last full capacity" differs significantly from the design capacity, your battery is probably broken. Try to claim your warranty.
Q: My problem is not listed above. Where should I go next?
A: Don't fear to contact me, Dennis Nienhüser, directly. The Gentoo Forums are a good place to get help as well. If you prefer IRC, try the #gentoo-laptop channel at irc.freenode.net.

Каталог: pub -> docs books -> Linux -> Linux 2
pub -> Буланов С. В. Кудрявцева Е. Л. Развитие креативности билингвов: путь от интеркультурности к формированию «человека мира»
pub -> «октябрьский лицей»
pub -> Самообследование гоу сош «Школа надомного обучения» №196 по направлениям деятельности. Общие вопросы
pub -> Занятие для математического кружка. Задачи работы
pub -> Доклад муниципальное образовательное
pub -> Публичный доклад. 2013 год Общая характеристика образовательного учреждения. Место расположения
pub -> Публичный доклад муниципального общеобразовательного учреждения средней общеобразовательной школы №13

Поделитесь с Вашими друзьями:
1   ...   19   20   21   22   23   24   25   26   ...   50

База данных защищена авторским правом ©nethash.ru 2019
обратиться к администрации

войти | регистрация
    Главная страница

загрузить материал