Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] shutting off the HD on a laptop
- Date: Sat, 5 Nov 2005 10:13:46 +0100
- From: Tobias Diedrich <ranma@example.com>
- Subject: Re: [tlug] shutting off the HD on a laptop
- References: <mailman.1.1131073205.21963.tlug@example.com> <436AD7BF.5010706@example.com> <30ce84360511032043p4d3a8726n1739e38ddd00e0d@example.com> <87wtjp80sr.fsf@example.com>
- User-agent: Mutt/1.5.11
Stephen J. Turnbull wrote: > There's also a daemon called flushd or something like that that can > inhibit flushes for a relatively long period of time. noflushd IIRC, but AFAIK that one is obsoleted by the introduction of /proc/sys/vm/laptop_mode in recent 2.6-kernels. >From Documentation/laptop_mode.txt: --------------------------------[ cut here ]--------------------------------------- How to conserve battery power using laptop-mode ----------------------------------------------- Document Author: Bart Samwel (bart@example.com) Date created: January 2, 2004 Last modified: July 10, 2004 Introduction ------------ Laptop mode is used to minimize the time that the hard disk needs to be spun up, to conserve battery power on laptops. It has been reported to cause significant power savings. Contents -------- * Introduction * Installation * Caveats * The Details * Tips & Tricks * Control script * ACPI integration * Monitoring tool Installation ------------ To use laptop mode, you don't need to set any kernel configuration options or anything. Simply install all the files included in this document, and laptop mode will automatically be started when you're on battery. For your convenience, a tarball containing an installer can be downloaded at: http://www.xs4all.nl/~bsamwel/laptop_mode/tools To configure laptop mode, you need to edit the configuration file, which is located in /etc/default/laptop-mode on Debian-based systems, or in /etc/sysconfig/laptop-mode on other systems. Unfortunately, automatic enabling of laptop mode does not work for laptops that don't have ACPI. On those laptops, you need to start laptop mode manually. To start laptop mode, run "laptop_mode start", and to stop it, run "laptop_mode stop". (Note: The laptop mode tools package now has experimental support for APM, you might want to try that first.) Caveats ------- * The downside of laptop mode is that you have a chance of losing up to 10 minutes of work. If you cannot afford this, don't use it! The supplied ACPI scripts automatically turn off laptop mode when the battery almost runs out, so that you won't lose any data at the end of your battery life. * Most desktop hard drives have a very limited lifetime measured in spindown cycles, typically about 50.000 times (it's usually listed on the spec sheet). Check your drive's rating, and don't wear down your drive's lifetime if you don't need to. * If you mount some of your ext3/reiserfs filesystems with the -n option, then the control script will not be able to remount them correctly. You must set DO_REMOUNTS=0 in the control script, otherwise it will remount them with the wrong options -- or it will fail because it cannot write to /etc/mtab. * If you have your filesystems listed as type "auto" in fstab, like I did, then the control script will not recognize them as filesystems that need remounting. You must list the filesystems with their true type instead. * It has been reported that some versions of the mutt mail client use file access times to determine whether a folder contains new mail. If you use mutt and experience this, you must disable the noatime remounting by setting the option DO_REMOUNT_NOATIME to 0 in the configuration file. The Details ----------- Laptop mode is controlled by the knob /proc/sys/vm/laptop_mode. This knob is present for all kernels that have the laptop mode patch, regardless of any configuration options. When the knob is set, any physical disk I/O (that might have caused the hard disk to spin up) causes Linux to flush all dirty blocks. The result of this is that after a disk has spun down, it will not be spun up anymore to write dirty blocks, because those blocks had already been written immediately after the most recent read operation. The value of the laptop_mode knob determines the time between the occurrence of disk I/O and when the flush is triggered. A sensible value for the knob is 5 seconds. Setting the knob to 0 disables laptop mode. To increase the effectiveness of the laptop_mode strategy, the laptop_mode control script increases dirty_expire_centisecs and dirty_writeback_centisecs in /proc/sys/vm to about 10 minutes (by default), which means that pages that are dirtied are not forced to be written to disk as often. The control script also changes the dirty background ratio, so that background writeback of dirty pages is not done anymore. Combined with a higher commit value (also 10 minutes) for ext3 or ReiserFS filesystems (also done automatically by the control script), this results in concentration of disk activity in a small time interval which occurs only once every 10 minutes, or whenever the disk is forced to spin up by a cache miss. The disk can then be spun down in the periods of inactivity. If you want to find out which process caused the disk to spin up, you can gather information by setting the flag /proc/sys/vm/block_dump. When this flag is set, Linux reports all disk read and write operations that take place, and all block dirtyings done to files. This makes it possible to debug why a disk needs to spin up, and to increase battery life even more. The output of block_dump is written to the kernel output, and it can be retrieved using "dmesg". When you use block_dump and your kernel logging level also includes kernel debugging messages, you probably want to turn off klogd, otherwise the output of block_dump will be logged, causing disk activity that is not normally there. Configuration ------------- The laptop mode configuration file is located in /etc/default/laptop-mode on Debian-based systems, or in /etc/sysconfig/laptop-mode on other systems. It contains the following options: MAX_AGE: Maximum time, in seconds, of hard drive spindown time that you are confortable with. Worst case, it's possible that you could lose this amount of work if your battery fails while you're in laptop mode. MINIMUM_BATTERY_MINUTES: Automatically disable laptop mode if the remaining number of minutes of battery power is less than this value. Default is 10 minutes. AC_HD/BATT_HD: The idle timeout that should be set on your hard drive when laptop mode is active (BATT_HD) and when it is not active (AC_HD). The defaults are 20 seconds (value 4) for BATT_HD and 2 hours (value 244) for AC_HD. The possible values are those listed in the manual page for "hdparm" for the "-S" option. HD: The devices for which the spindown timeout should be adjusted by laptop mode. Default is /dev/hda. If you specify multiple devices, separate them by a space. READAHEAD: Disk readahead, in 512-byte sectors, while laptop mode is active. A large readahead can prevent disk accesses for things like executable pages (which are loaded on demand while the application executes) and sequentially accessed data (MP3s). DO_REMOUNTS: The control script automatically remounts any mounted journaled filesystems with approriate commit interval options. When this option is set to 0, this feature is disabled. DO_REMOUNT_NOATIME: When remounting, should the filesystems be remounted with the noatime option? Normally, this is set to "1" (enabled), but there may be programs that require access time recording. DIRTY_RATIO: The percentage of memory that is allowed to contain "dirty" or unsaved data before a writeback is forced, while laptop mode is active. Corresponds to the /proc/sys/vm/dirty_ratio sysctl. DIRTY_BACKGROUND_RATIO: The percentage of memory that is allowed to contain "dirty" or unsaved data after a forced writeback is done due to an exceeding of DIRTY_RATIO. Set this nice and low. This corresponds to the /proc/sys/vm/dirty_background_ratio sysctl. Note that the behaviour of dirty_background_ratio is quite different when laptop mode is active and when it isn't. When laptop mode is inactive, dirty_background_ratio is the threshold percentage at which background writeouts start taking place. When laptop mode is active, however, background writeouts are disabled, and the dirty_background_ratio only determines how much writeback is done when dirty_ratio is reached. DO_CPU: Enable CPU frequency scaling when in laptop mode. (Requires CPUFreq to be setup. See Documentation/cpu-freq/user-guide.txt for more info. Disabled by default.) CPU_MAXFREQ: When on battery, what is the maximum CPU speed that the system should use? Legal values are "slowest" for the slowest speed that your CPU is able to operate at, or a value listed in /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies. Tips & Tricks ------------- * Bartek Kania reports getting up to 50 minutes of extra battery life (on top of his regular 3 to 3.5 hours) using a spindown time of 5 seconds (BATT_HD=1). * You can spin down the disk while playing MP3, by setting disk readahead to 8MB (READAHEAD=16384). Effectively, the disk will read a complete MP3 at once, and will then spin down while the MP3 is playing. (Thanks to Bartek Kania.) * Drew Scott Daniels observed: "I don't know why, but when I decrease the number of colours that my display uses it consumes less battery power. I've seen this on powerbooks too. I hope that this is a piece of information that might be useful to the Laptop Mode patch or it's users." * In syslog.conf, you can prefix entries with a dash ``-'' to omit syncing the file after every logging. When you're using laptop-mode and your disk doesn't spin down, this is a likely culprit. * Richard Atterer observed that laptop mode does not work well with noflushd (http://noflushd.sourceforge.net/), it seems that noflushd prevents laptop-mode from doing its thing. * If you're worried about your data, you might want to consider using a USB memory stick or something like that as a "working area". (Be aware though that flash memory can only handle a limited number of writes, and overuse may wear out your memory stick pretty quickly. Do _not_ use journalling filesystems on flash memory sticks.) --------------------------------[ cut here ]--------------------------------------- Above document further includes a shell script and some c code, which I left out. -- Tobias PGP: http://9ac7e0bc.uguu.de Mail over UUCP over Bicycle+Train
- Follow-Ups:
- Re: [tlug] shutting off the HD on a laptop
- From: Josh Glover
- References:
- [tlug] shutting off the HD on a laptop
- From: David Riggs
- Re: [tlug] shutting off the HD on a laptop
- From: Ian Wells
- Re: [tlug] shutting off the HD on a laptop
- From: Stephen J. Turnbull
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] debian dselect
- Next by Date: Re: [tlug] shutting off the HD on a laptop
- Previous by thread: Re: [tlug] shutting off the HD on a laptop
- Next by thread: Re: [tlug] shutting off the HD on a laptop
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links