Return to the Laptop Mode home page, the
Laptop Mode Tools home page or to
Bart Samwel's home page.
Laptop Mode and Laptop Mode Tools FAQ
Updated: October 6, 2006.
1. Things You Might Want To Know
Linux Journal article
There's an article in the Linux Journal September 2004 issue.
It can be found online at http://www.linuxjournal.com/article/7539.
It's not really up-to-date anymore BTW. The most important conclusion from the
article is that it doesn't really pay to increase the spun-down time over a
minute. I often get mails in which people tell me that they want to go up to
one hour or more without disk activity. This is nice for noise reduction purposes,
but not for saving power.
FOSDEM 2006 presentation
I did a talk on power saving, Laptop Mode and the Laptop Mode Tools at FOSDEM
2006. A pdf version of the presentation can be downloaded
here.
Spinning Down May Kill Hard Drives
Desktop hard drives are usually rated for only 40,000-50,000 spinups,
and one spinup every 10 minutes will kill your 40,000-spinup HD in 277 days.
So this is NOT recommended for server use, unless you increase the spinup
interval dramatically, to say once every hour or two. Laptop hard drives are
usually rated for around 300,000 spinups, so those will last about 2083 days or
6 years if you have them powered on 24-7.
If my machine crashes or runs out of power, will I lose all my work?
If you have laptop mode enabled and your machine crashes, then you will lose up
to MAX_LOST_WORK_SECONDS seconds of work. If you really need to have something
written to disk, issue the "sync" command. If you have laptop mode enabled
and your machine runs out of power, you will not lose as much work (provided
you have an ACPI laptop, as most current PC laptops are) because laptop mode
is automatically disabled when the battery almost runs out.
2. Relationship with Other Packages
What does all this have to do with Smart Spindown?
Nothing really. You use Smart Spindown if your hard drive can't spin
down by itself, or if you're irritated by repeated spindown attempts
while you're actually actively using the computer and don't want
spindowns at all. It's not well-integrated with Laptop Mode Tools and
it isn't maintained at the moment, so I'd advise against using it. :)
What is the relationship between Laptop Mode Tools and the script
in the kernel documentation?
Laptop Mode Tools is a fork of the script in the kernel documentation.
The script in the kernel documentation is currently pretty much
unmaintained AFAIK, so I don't recommend using it.
What is the relationship between the Ubuntu package "laptop-mode"
and the Debian package "laptop-mode-tools"?
There is a big thread about this on ubuntuforums,
http://ubuntuforums.org/showthread.php?t=36976
. Ubuntu has a rather outdated package for controlling
laptop mode, based on the aforementioned kernel documentation script.
Laptop mode tools basically is a much more recent version of the same
code. Ubuntu apparently also has laptop-mode-tools available, so I
advise you to use this package instead of laptop-mode. If it's not in
the Ubuntu repository, you can download it from a Debian apt source or
from the laptop mode tools homepage.
How does Laptop Mode Tools relate to noflushd?
It doesn't. Don't install both together. Noflushd does the same thing for
your disks as laptop mode tools if you don't run a journaling filesystem
such as ext3, ReiserFS or XFS. If you do, Laptop Mode Tools is currently your
only option.
3. Is Laptop Mode Enabled?
How do I check if laptop mode is enabled?
Do cat /proc/sys/vm/laptop_mode.
If it contains a nonzero value, then laptop mode is enabled, if it says
0, then it isn't.
What's /var/run/laptop-mode-enabled
got to do with things?
Well, this file is created and destroyed by the
laptop-mode
init script to enable/disable laptop mode activity. If this file is not present,
then laptop mode tools will not do a thing except disable itself, even when you
unplug your computer from the mains.
And what about /etc/default/laptop-mode?
That's only supported for backward compatibility with the Ubuntu laptop-mode package. It
contains a setting using which you can enable or disable laptop mode
entirely.
4. Configuration Questions / Issues
Can I force laptop mode on/off?
Yes, kind of. If you want to manually control laptop mode, you need to set all ENABLE_LAPTOP_MODE_* to 1, and then control laptop mode by manually calling the /etc/init.d/laptop-mode script with the "start" and "stop" arguments.
Note that the /usr/sbin/laptop_mode command does not support the "start" and "stop" commands anymore. These commands interfere with the low-battery detection code, and they default to "auto" for that reason. This design flaw will be corrected by the 2.x major release, which will feature a profile-based configuration system that will allow manual profile switching without interfering with the low-battery detection code.
I have two hard drives, can I configure Laptop Mode to affect only
one of them?
Set HD="/dev/hdX /dev/hdY" in /etc/laptop-mode/laptop-mode.conf,
where /dev/hdX and /dev/hdY are the device names that you want laptop
mode to affect. This doesn't quite work though: the kernel switch
(which delays all writes) doesn't discriminate between drives. You can
also limit which partitions are affected by the remounting, using the
PARTITIONS configuration setting, but again, this doesn't fully
disable laptop mode for the other partitions.
I set PARTITIONS and now it doesn't work anymore
at all.
You have to include the default partitions (the partitions of the
drives listed in the HD configuration setting) as well. In version 1.06
and higher you can use the "auto" keyword to
indicate "and remount all of the default ones as well". "Default" here
means "partitions that contain the device name of a hard drive in HD",
i.e. if your partition is /dev/hda3 and you have HD=/dev/hda, then
/dev/hda3 is part of the default partitions, but if it is aptly named
/dev/hdx7 then it isn't. :)
I set REMOUNT_PARTITIONS to "/ /mnt /usr" and it doesn't work.
You have to include the partitions'
devices, not their mount
points. So you should list things like "/dev/hda2 /dev/hdb1". If you're
using version 1.06 or higher then you don't have this problem, as this
version supports mount points as well as device names in
REMOUNT_PARTITIONS (or PARTITIONS, as it's called in the new config
file format introduced in version 1.07).
Why does syslogd sync all the time? Can I turn this off?
Yes, you can. In syslog.conf, you have to place a dash (-) before the
log file name, e.g. the line kern.*
/var/log/kern.log becomes kern.*
-/var/log/kern.log. In addition, you can use lm-syslog-setup (included in
laptop mode tools) to use different syslog.conf files based on whether
you're running on battery or on AC power. This creates three different syslog.conf files in /etc: syslog-on-battery.conf for
battery mode, syslog-on-ac-with-lm.conf
for AC mode with Laptop Mode enabled, and syslog-on-ac-without-lm.conf
for AC mode with Laptop Mode disabled. Laptop mode tools will then take
care of syslog.conf, by making it a link to the appropriate config file
based on the power and laptop mode state. After running lm-syslog-setup, you can
perhaps modify the "battery" version of the syslog.conf so that it
never syncs, while leaving the syncs intact when you're on AC.
5. Spinup Debugging
My disk spins up all the time and I have no clue what causes this.
Can I debug this?
Yes, you can. But first, check that you have modified your syslog.conf
to not sync, as described in the next question. To debug disk activity,
you can do:
echo
1 > /proc/sys/vm/block_dump
(Warning: you must disable syslogd before
you do this, or you must make sure that kernel output is not logged. If
you forget this, your system may get into a feedback loop, where
syslogd causes disk activity, this causes kernel output, and this
causes syslogd to do more disk activity, etcetera!)
This enables file/disk activity debugging in the kernel. You can read
the output using dmesg.
When you're done, disable block dump using
echo
0 > /proc/sys/vm/block_dump
NOTE: Recently a tool called lm-profiler was
added to laptop-mode-tools, which does all this for you. It also
detects network services that you might not want running, and it can
install the services' init scripts into laptop mode's new
"start/stop" directory structure, so that they are automatically
stopped when you are working on battery.
6. Common Problems
When I start laptop mode, it complains about an unknown mount option.
- Least likely
option: You could have a 2.4 kernel version that doesn't support
the commit= option for
ReiserFS. To be honest, I have no clue whether that support was ever
backported, so if anyone reading this has a 2.4 kernel running, try
remounting your reiserfs partition with -o remount,commit=5 and tell me
if it complains about an unknown mount option.
- Most
likely option: Your root filesystem is mounted as ext2
instead of ext3, because you did all of the following:
- You compiled ext3 as a kernel module.
- You don't use an initrd, or if you do, it does not load the ext3 module.
- You did not explicitly specify the rootfstype as "ext3" in
the kernel
boot parameters. This means it is autodetected as ext2 at boot
time,
because it lacks an ext3 module.
This problem is very nasty, because it is impossible to detect it --
/proc/mounts will list the
rootfstype as rootfs,
which tells you nothing, and mount
as well as /etc/mtab will
tell you the fstype is in fact ext3 -- which is an incorrect guess, taken from /etc/fstab. It puts your data
at risk because you do not have journalling enabled, while you think
you do. I've added a BIG FAT WARNING text when this happens in version
1.06 of laptop mode tools.
My log / laptop_mode output says hdc:
drive_cmd: status=0x51 { DriveReady SeekComplete Error }
Then hdc is probably not a hard drive, nor a CD-ROM, and you should
remove it from the HD parameter in /etc/laptop-mode/laptop-mode.conf.
Fortunately, this doesn't actually break anything, so you can simply
ignore the error messages as well. Recent versions of laptop-mode-tools
correctly autodetect CD-ROM drives, so the error messages should be gone
if you upgrade to the most recent version.
I have an SATA disk and it doesn't work.
Spindown timeouts don't currently work on SATA drives, because the
Linux kernel does not support that properly. There are patches available
that add this support. Check out
http://www.thinkwiki.org/wiki/Problems_with_SATA_and_Linux
for all SATA-on-Linux problems. For laptop mode to work, you want the libata_passthru patch. It will be included
in the Linux kernel starting from version 2.6.15. Note: You also need a
recent version of hdparm in order to make this work!
I have a SCSI disk and it doesn't work.
Starting from version 1.20 laptop-mode-tools supports SCSI drives.
You have to make sure you have sdparm installed though!
I run Slackware and Laptop Mode isn't initialized correctly on boot.
This is caused by the fact that Slackware doesn't follow the Filesystem Hierarchy Standard
and it doesn't completely clear /var/run on boot. It will work when you include a call to
/etc/rc.d/init.d/laptop-mode restart
in your rc.local.
I have an Apple notebook, and when I unplug the AC adapter Laptop
Mode isn't enabled automatically.
If you are running pmud, then
you need to have the line "/usr/sbin/laptop_mode auto" in the file
/etc/power/pwrctl-local. Version 1.05 and higher add this automatically, I
just haven't had any reports that this actually works so be warned.
Versions 1.05 and up also install pbbuttonsd
support, so that should work fine as well. Report back to me if it doesn't!
My system gets horribly slow!
If you don't have that much RAM, you probably want to consider lowering
the READAHEAD value in /etc/laptop-mode/laptop-mode.conf.
The default used to be 8MB, it was lowered to 3MB in version 1.05 for
exactly this reason.
I upgraded to version 1.06 or higher and hibernation no longer
works / is horribly slow! What causes this?
This is caused by the introduction of write caching control. Apparently
disbling the write cache makes some drives horribly slow. Set
DO_WRITECACHE=0 (version 1.06) or CONTROL_HD_WRITECACHE=0 (version 1.07
upward) to fix this. In a future version, this may be fixed by only
disabling the write caches when the battery level is low. Note that
writecache control is disabled by default in more recent versions.
I've set LM_BATT_HD_IDLE_TIMEOUT_SECONDS to 20 seconds, but the drive
spins down after 5 seconds, what's going on?
Some drives override the idle timeout setting (hdparm -S) when you also
set an aggressive power management level (hdparm -B). Set
CONTROL_HD_POWERMGMT=0 (supported from version 1.07) to stop laptop
mode tools from fiddling with the HD powermanagement setting.
I've set LM_BATT_HD_IDLE_TIMEOUT_SECONDS to 5 seconds, but the drive
doesn't spin down at all.
Well, some drives have a specific minimum to the idle timeout values they
support. Try increasing the value to 120 seconds and see if that works, then
work your way back to the lowest value that still works.
I experience system freezes every once in a while, is this normal?
This is a bug in hardware or the Linux kernel,
triggered by something laptop mode tools does. Try setting
CONTROL_HD_POWERMGMT=0. This fixes the freezes for some people.
The default for CONTROL_HD_POWERMGMT was changed to 0 in version 1.11
for exactly this reason. Otherwise, for now, downgrade to a kernel
2.6.10 or earlier.
Laptop mode causes filesystem corruption.
There has been a lengthy thread on the Linux Kernel mailing list about this,
and the cause was determined to be the ipw2200 wireless network driver,
version 1.0.8 (http://bughost.org/bugzilla/show_bug.cgi?id=821).
This driver causes random memory corruption after some amount of network
activity, and it will write a message "Firmware error detected. Restarting."
to the kernel output. The memory corruption only happens the first time
the message is shown (unless you have compiled the driver with some debugging
options set), and can corrupt pretty much anything, including filesystem
(meta)data that resides in memory. The chance that the overwritten data is,
in fact, filesystem data is larger when you're running laptop mode, because
laptop mode keeps filesystem data in memory for a longer period of time, thereby
increasing the proportion of memory that contains filesystem data.
I have an LVM partition and it doesn't get remounted.
This could be because laptop mode tools does not notice that the LVM
partitions are on one of the hard drives that are listed in the HD
configuration setting. You should list the devices by hand in the
PARTITIONS configuration setting. (But: also check out the items on
this configuration setting in the Configuration section of the FAQ!)
I started using SELinux / upgraded to Fedora Core 4 and now Laptop
Mode doesn't start when I unplug the power cord.
This is caused by SELinux controlling acpid / apmd. How to change this
in FC4 (contributed by Vesko T. Tomov):
- Click on Desktop in the panel --> System settings -->
Security level
- Enter root password
- Click on SELinux tab
- Click on "SELinux Service Protection"
- Check box next to: Disable SELinux protection for apmd daemon,
and click OK
- Restart acpid
I run a 2.6.12 Linux kernel. Why does Laptop Mode no longer start
when I close the lid?
Some guy decided to delete the whole /proc/acpi/buttons directory,
without creating a replacement. It was reintroduced in 2.6.13, so I
suggest that you upgrade.
Why doesn't MUTT notice incoming mail anymore?
That's because Laptop Mode Tools remounts your filesystems with the
"noatime" option, which prevents the updating of access times, while
mutt is one of the few programs that actually use the access times. Set
DO_REMOUNT_NOATIME=0 (CONTROL_NOATIME in recent versions) in laptop-mode.conf
to fix this. Note that the default for this option has been changed to 0 recently.
Laptop mode stops working after I resume from hibernate.
Well, you'll have to restart the laptop-mode service after resuming from
hibernation. The hibernate configuration file has support for starting/stopping
services, you can use that.
After the X screensaver has kicked in once, my X screen blanking
settings are reset.
Yes, xscreensaver resets the X screen blanking settings. I'm trying to
figure out how to fix this. Any ideas? Send me an e-mail!
I monitor my drives using SMART, and my drive won't spin down.
Disable automatic offline testing with "smartctl -o 0". It prevents some
drives from spinning down properly.
One of my ext3/reiserfs partitions doesn't get remounted with the
commit= option.
Check if it is listed as type "auto" in fstab. Laptop mode tools cannot currently
detect the filesystem type if it is mounted as type "auto". If you desperately
need this, drop me a line.
7. Laptop Mode Tools Development / Contribution
What are the currently outstanding wishlist items that I shouldn't
(or perhaps should) bug the
maintainer about?
- Not installing pbbuttonsd support on PC hardware, and not
installing ACPI+APM support on Mac hardware.
- It seems that LVM partitions' default settings for noatime are
not always correctly
read from /etc/fstab. May be an fstab layout issue or something, I
haven't been able to reproduce this. If anyone reading this has an LVM
volume, please try and mark it as "noatime" in fstab, start laptop
mode, stop laptop mode and check whether the noatime is still there --
and mail me if it isn't. Thanks!
Is there a Laptop Mode mailing list?
No. I'll create one if there is a lot of demand though.
I have written this great library called libnosync, will you
include it?
You wouldn't be the first. This library can be found in various
incarnations on the web, and I think there are at least half a dozen
people who have contacted me saying they either wrote this library, or
they were thinking about doing it. No, I will not include it in laptop
mode tools, as laptop mode tools is an architecture independent
package. I might add support
for enabling/disabling it together with laptop mode though. I have some
plans to build a clean, configurable version of this library (which
would allow control at the user and process level, i.e. "disallow sync
only for emacs and vi, but not when they're run by root" and which
would be able to report all syncs to a log file). This would become a
separate package though!
I have a great idea for saving more power. Will you include it in
Laptop Mode Tools?
If you can write it as a plugin, to be placed in /etc/laptop-mode/batt-start or the
like, then you can put it on the web yourself, and I'll gladly link to
your site. I'll even put it on my site, if you don't have a website to
put it on. If it's more complicated than that, or if it will benefit a
lot of people, then I'll consider including it.
8. Other Questions
What if my question isn't in here?
Read the manual pages (the one you want to read is the one called laptop-mode.conf). If that doesn't
give you the answer, contact Bart
Samwel (bart@samwel.tk).