~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/admin-guide/laptops/laptop-mode.rst

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/admin-guide/laptops/laptop-mode.rst (Version linux-6.11.5) and /Documentation/admin-guide/laptops/laptop-mode.rst (Version linux-2.6.0)


  1 ==============================================    
  2 How to conserve battery power using laptop-mod    
  3 ==============================================    
  4                                                   
  5 Document Author: Bart Samwel (bart@samwel.tk)     
  6                                                   
  7 Date created: January 2, 2004                     
  8                                                   
  9 Last modified: December 06, 2004                  
 10                                                   
 11 Introduction                                      
 12 ------------                                      
 13                                                   
 14 Laptop mode is used to minimize the time that     
 15 to conserve battery power on laptops. It has b    
 16 power savings.                                    
 17                                                   
 18 .. Contents                                       
 19                                                   
 20    * Introduction                                 
 21    * Installation                                 
 22    * Caveats                                      
 23    * The Details                                  
 24    * Tips & Tricks                                
 25    * Control script                               
 26    * ACPI integration                             
 27    * Monitoring tool                              
 28                                                   
 29                                                   
 30 Installation                                      
 31 ------------                                      
 32                                                   
 33 To use laptop mode, you don't need to set any     
 34 or anything. Simply install all the files incl    
 35 laptop mode will automatically be started when    
 36 your convenience, a tarball containing an inst    
 37                                                   
 38         http://www.samwel.tk/laptop_mode/lapto    
 39                                                   
 40 To configure laptop mode, you need to edit the    
 41 located in /etc/default/laptop-mode on Debian-    
 42 /etc/sysconfig/laptop-mode on other systems.      
 43                                                   
 44 Unfortunately, automatic enabling of laptop mo    
 45 laptops that don't have ACPI. On those laptops    
 46 mode manually. To start laptop mode, run "lapt    
 47 stop it, run "laptop_mode stop". (Note: The la    
 48 has experimental support for APM, you might wa    
 49                                                   
 50                                                   
 51 Caveats                                           
 52 -------                                           
 53                                                   
 54 * The downside of laptop mode is that you have    
 55   minutes of work. If you cannot afford this,     
 56   scripts automatically turn off laptop mode w    
 57   so that you won't lose any data at the end o    
 58                                                   
 59 * Most desktop hard drives have a very limited    
 60   cycles, typically about 50.000 times (it's u    
 61   Check your drive's rating, and don't wear do    
 62   don't need to.                                  
 63                                                   
 64 * If you mount some of your ext3/reiserfs file    
 65   the control script will not be able to remou    
 66   DO_REMOUNTS=0 in the control script, otherwi    
 67   wrong options -- or it will fail because it     
 68                                                   
 69 * If you have your filesystems listed as type     
 70   the control script will not recognize them a    
 71   You must list the filesystems with their tru    
 72                                                   
 73 * It has been reported that some versions of t    
 74   times to determine whether a folder contains    
 75   experience this, you must disable the noatim    
 76   DO_REMOUNT_NOATIME to 0 in the configuration    
 77                                                   
 78                                                   
 79 The Details                                       
 80 -----------                                       
 81                                                   
 82 Laptop mode is controlled by the knob /proc/sy    
 83 present for all kernels that have the laptop m    
 84 configuration options. When the knob is set, a    
 85 have caused the hard disk to spin up) causes L    
 86 result of this is that after a disk has spun d    
 87 anymore to write dirty blocks, because those b    
 88 immediately after the most recent read operati    
 89 knob determines the time between the occurrenc    
 90 is triggered. A sensible value for the knob is    
 91 0 disables laptop mode.                           
 92                                                   
 93 To increase the effectiveness of the laptop_mo    
 94 control script increases dirty_expire_centisec    
 95 /proc/sys/vm to about 10 minutes (by default),    
 96 dirtied are not forced to be written to disk a    
 97 changes the dirty background ratio, so that ba    
 98 is not done anymore. Combined with a higher co    
 99 ext3 or ReiserFS filesystems (also done automa    
100 this results in concentration of disk activity    
101 occurs only once every 10 minutes, or whenever    
102 a cache miss. The disk can then be spun down i    
103                                                   
104                                                   
105 Configuration                                     
106 -------------                                     
107                                                   
108 The laptop mode configuration file is located     
109 Debian-based systems, or in /etc/sysconfig/lap    
110 contains the following options:                   
111                                                   
112 MAX_AGE:                                          
113                                                   
114 Maximum time, in seconds, of hard drive spindo    
115 comfortable with. Worst case, it's possible th    
116 amount of work if your battery fails while you    
117                                                   
118 MINIMUM_BATTERY_MINUTES:                          
119                                                   
120 Automatically disable laptop mode if the remai    
121 battery power is less than this value. Default    
122                                                   
123 AC_HD/BATT_HD:                                    
124                                                   
125 The idle timeout that should be set on your ha    
126 is active (BATT_HD) and when it is not active     
127 20 seconds (value 4) for BATT_HD  and 2 hours     
128 possible values are those listed in the manual    
129 "-S" option.                                      
130                                                   
131 HD:                                               
132                                                   
133 The devices for which the spindown timeout sho    
134 Default is /dev/hda. If you specify multiple d    
135                                                   
136 READAHEAD:                                        
137                                                   
138 Disk readahead, in 512-byte sectors, while lap    
139 readahead can prevent disk accesses for things    
140 loaded on demand while the application execute    
141 (MP3s).                                           
142                                                   
143 DO_REMOUNTS:                                      
144                                                   
145 The control script automatically remounts any     
146 with appropriate commit interval options. When    
147 feature is disabled.                              
148                                                   
149 DO_REMOUNT_NOATIME:                               
150                                                   
151 When remounting, should the filesystems be rem    
152 Normally, this is set to "1" (enabled), but th    
153 access time recording.                            
154                                                   
155 DIRTY_RATIO:                                      
156                                                   
157 The percentage of memory that is allowed to co    
158 before a writeback is forced, while laptop mod    
159 the /proc/sys/vm/dirty_ratio sysctl.              
160                                                   
161 DIRTY_BACKGROUND_RATIO:                           
162                                                   
163 The percentage of memory that is allowed to co    
164 after a forced writeback is done due to an exc    
165 this nice and low. This corresponds to the /pr    
166 sysctl.                                           
167                                                   
168 Note that the behaviour of dirty_background_ra    
169 when laptop mode is active and when it isn't.     
170 dirty_background_ratio is the threshold percen    
171 start taking place. When laptop mode is active    
172 are disabled, and the dirty_background_ratio o    
173 is done when dirty_ratio is reached.              
174                                                   
175 DO_CPU:                                           
176                                                   
177 Enable CPU frequency scaling when in laptop mo    
178 See Documentation/admin-guide/pm/cpufreq.rst f    
179                                                   
180 CPU_MAXFREQ:                                      
181                                                   
182 When on battery, what is the maximum CPU speed    
183 values are "slowest" for the slowest speed tha    
184 or a value listed in /sys/devices/system/cpu/c    
185                                                   
186                                                   
187 Tips & Tricks                                     
188 -------------                                     
189                                                   
190 * Bartek Kania reports getting up to 50 minute    
191   of his regular 3 to 3.5 hours) using a spind    
192                                                   
193 * You can spin down the disk while playing MP3    
194   to 8MB (READAHEAD=16384). Effectively, the d    
195   once, and will then spin down while the MP3     
196   Kania.)                                         
197                                                   
198 * Drew Scott Daniels observed: "I don't know w    
199   of colours that my display uses it consumes     
200   this on powerbooks too. I hope that this is     
201   might be useful to the Laptop Mode patch or     
202                                                   
203 * In syslog.conf, you can prefix entries with     
204   file after every logging. When you're using     
205   spin down, this is a likely culprit.            
206                                                   
207 * Richard Atterer observed that laptop mode do    
208   (http://noflushd.sourceforge.net/), it seems    
209   from doing its thing.                           
210                                                   
211 * If you're worried about your data, you might    
212   memory stick or something like that as a "wo    
213   that flash memory can only handle a limited     
214   may wear out your memory stick pretty quickl    
215   filesystems on flash memory sticks.)            
216                                                   
217                                                   
218 Configuration file for control and ACPI batter    
219 ----------------------------------------------    
220                                                   
221 This allows the tunables to be changed for the    
222 configuration file                                
223                                                   
224 It should be installed as /etc/default/laptop-    
225 /etc/sysconfig/laptop-mode on Red Hat, SUSE, M    
226                                                   
227 Config file::                                     
228                                                   
229   # Maximum time, in seconds, of hard drive sp    
230   # comfortable with. Worst case, it's possibl    
231   # amount of work if your battery fails you w    
232   #MAX_AGE=600                                    
233                                                   
234   # Automatically disable laptop mode when the    
235   # that you have left goes below this thresho    
236   MINIMUM_BATTERY_MINUTES=10                      
237                                                   
238   # Read-ahead, in 512-byte sectors. You can s    
239   # by setting the disk readahead to 8MB (READ    
240   # will read a complete MP3 at once, and will    
241   # playing.                                      
242   #READAHEAD=4096                                 
243                                                   
244   # Shall we remount journaled fs. with approp    
245   #DO_REMOUNTS=1                                  
246                                                   
247   # And shall we add the "noatime" option to t    
248   #DO_REMOUNT_NOATIME=1                           
249                                                   
250   # Dirty synchronous ratio.  At this percenta    
251   # which                                         
252   # calls write() does its own writeback          
253   #DIRTY_RATIO=40                                 
254                                                   
255   #                                               
256   # Allowed dirty background ratio, in percent    
257   # exceeded, the kernel will wake flusher thr    
258   # amount of dirty memory to dirty_background    
259   # so once some writeout has commenced, we do    
260   #                                               
261   #DIRTY_BACKGROUND_RATIO=5                       
262                                                   
263   # kernel default dirty buffer age               
264   #DEF_AGE=30                                     
265   #DEF_UPDATE=5                                   
266   #DEF_DIRTY_BACKGROUND_RATIO=10                  
267   #DEF_DIRTY_RATIO=40                             
268   #DEF_XFS_AGE_BUFFER=15                          
269   #DEF_XFS_SYNC_INTERVAL=30                       
270   #DEF_XFS_BUFD_INTERVAL=1                        
271                                                   
272   # This must be adjusted manually to the valu    
273   # on 2.4, until the XFS people change their     
274   # centisecs. This can be automated, but it's    
275   # needs# some fixes. On 2.6 kernels, XFS use    
276   # external interfaces, and that is currently    
277   # need to change this on 2.6.                   
278   #XFS_HZ=100                                     
279                                                   
280   # Should the maximum CPU frequency be adjust    
281   # Requires CPUFreq to be setup.                 
282   # See Documentation/admin-guide/pm/cpufreq.r    
283   #DO_CPU=0                                       
284                                                   
285   # When on battery what is the maximum CPU sp    
286   # use? Legal values are "slowest" for the sl    
287   # CPU is able to operate at, or a value list    
288   # /sys/devices/system/cpu/cpu0/cpufreq/scali    
289   # Only applicable if DO_CPU=1.                  
290   #CPU_MAXFREQ=slowest                            
291                                                   
292   # Idle timeout for your hard drive (man hdpa    
293   # Default is 2 hours on AC (AC_HD=244) and 2    
294   #AC_HD=244                                      
295   #BATT_HD=4                                      
296                                                   
297   # The drives for which to adjust the idle ti    
298   # e.g. HD="/dev/hda /dev/hdb".                  
299   #HD="/dev/hda"                                  
300                                                   
301   # Set the spindown timeout on a hard drive?     
302   #DO_HD=1                                        
303                                                   
304                                                   
305 Control script                                    
306 --------------                                    
307                                                   
308 Please note that this control script works for    
309 to Kiko Piris).                                   
310                                                   
311 Control script::                                  
312                                                   
313   #!/bin/bash                                     
314                                                   
315   # start or stop laptop_mode, best run by a p    
316   # ac gets connected/disconnected from a lapt    
317   #                                               
318   # install as /sbin/laptop_mode                  
319   #                                               
320   # Contributors to this script:   Kiko Piris     
321   #                              Bart Samwel      
322   #                              Micha Feigin     
323   #                              Andrew Morton    
324   #                              Herve Eychenn    
325   #                              Dax Kelson       
326   #                                               
327   # Original Linux 2.4 version by: Jens Axboe     
328                                                   
329   ############################################    
330                                                   
331   # Source config                                 
332   if [ -f /etc/default/laptop-mode ] ; then       
333         # Debian                                  
334         . /etc/default/laptop-mode                
335   elif [ -f /etc/sysconfig/laptop-mode ] ; the    
336         # Others                                  
337           . /etc/sysconfig/laptop-mode            
338   fi                                              
339                                                   
340   # Don't raise an error if the config file is    
341   # set defaults instead:                         
342                                                   
343   # Maximum time, in seconds, of hard drive sp    
344   # comfortable with. Worst case, it's possibl    
345   # amount of work if your battery fails you w    
346   MAX_AGE=${MAX_AGE:-'600'}                       
347                                                   
348   # Read-ahead, in kilobytes                      
349   READAHEAD=${READAHEAD:-'4096'}                  
350                                                   
351   # Shall we remount journaled fs. with approp    
352   DO_REMOUNTS=${DO_REMOUNTS:-'1'}                 
353                                                   
354   # And shall we add the "noatime" option to t    
355   DO_REMOUNT_NOATIME=${DO_REMOUNT_NOATIME:-'1'    
356                                                   
357   # Shall we adjust the idle timeout on a hard    
358   DO_HD=${DO_HD:-'1'}                             
359                                                   
360   # Adjust idle timeout on which hard drive?      
361   HD="${HD:-'/dev/hda'}"                          
362                                                   
363   # spindown time for HD (hdparm -S values)       
364   AC_HD=${AC_HD:-'244'}                           
365   BATT_HD=${BATT_HD:-'4'}                         
366                                                   
367   # Dirty synchronous ratio.  At this percenta    
368   # calls write() does its own writeback          
369   DIRTY_RATIO=${DIRTY_RATIO:-'40'}                
370                                                   
371   # cpu frequency scaling                         
372   # See Documentation/admin-guide/pm/cpufreq.r    
373   DO_CPU=${CPU_MANAGE:-'0'}                       
374   CPU_MAXFREQ=${CPU_MAXFREQ:-'slowest'}           
375                                                   
376   #                                               
377   # Allowed dirty background ratio, in percent    
378   # exceeded, the kernel will wake flusher thr    
379   # amount of dirty memory to dirty_background    
380   # so once some writeout has commenced, we do    
381   #                                               
382   DIRTY_BACKGROUND_RATIO=${DIRTY_BACKGROUND_RA    
383                                                   
384   # kernel default dirty buffer age               
385   DEF_AGE=${DEF_AGE:-'30'}                        
386   DEF_UPDATE=${DEF_UPDATE:-'5'}                   
387   DEF_DIRTY_BACKGROUND_RATIO=${DEF_DIRTY_BACKG    
388   DEF_DIRTY_RATIO=${DEF_DIRTY_RATIO:-'40'}        
389   DEF_XFS_AGE_BUFFER=${DEF_XFS_AGE_BUFFER:-'15    
390   DEF_XFS_SYNC_INTERVAL=${DEF_XFS_SYNC_INTERVA    
391   DEF_XFS_BUFD_INTERVAL=${DEF_XFS_BUFD_INTERVA    
392                                                   
393   # This must be adjusted manually to the valu    
394   # on 2.4, until the XFS people change their     
395   # centisecs. This can be automated, but it's    
396   # some fixes. On 2.6 kernels, XFS uses USER_    
397   # interfaces, and that is currently always s    
398   # change this on 2.6.                           
399   XFS_HZ=${XFS_HZ:-'100'}                         
400                                                   
401   ############################################    
402                                                   
403   KLEVEL="$(uname -r |                            
404                {                                  
405                IFS='.' read a b c                 
406                echo $a.$b                         
407              }                                    
408   )"                                              
409   case "$KLEVEL" in                               
410         "2.4"|"2.6")                              
411                 ;;                                
412         *)                                        
413                 echo "Unhandled kernel version    
414                 exit 1                            
415                 ;;                                
416   esac                                            
417                                                   
418   if [ ! -e /proc/sys/vm/laptop_mode ] ; then     
419         echo "Kernel is not patched with lapto    
420         exit 1                                    
421   fi                                              
422                                                   
423   if [ ! -w /proc/sys/vm/laptop_mode ] ; then     
424         echo "You do not have enough privilege    
425         exit 1                                    
426   fi                                              
427                                                   
428   # Remove an option (the first parameter) of     
429   # a mount options string (the rest of the pa    
430   parse_mount_opts () {                           
431         OPT="$1"                                  
432         shift                                     
433         echo ",$*," | sed               \         
434          -e 's/,'"$OPT"'=[0-9]*,/,/g'   \         
435          -e 's/,,*/,/g'                 \         
436          -e 's/^,//'                    \         
437          -e 's/,$//'                              
438   }                                               
439                                                   
440   # Remove an option (the first parameter) wit    
441   # a mount option string (the rest of the par    
442   parse_nonumber_mount_opts () {                  
443         OPT="$1"                                  
444         shift                                     
445         echo ",$*," | sed               \         
446          -e 's/,'"$OPT"',/,/g'          \         
447          -e 's/,,*/,/g'                 \         
448          -e 's/^,//'                    \         
449          -e 's/,$//'                              
450   }                                               
451                                                   
452   # Find out the state of a yes/no option (e.g    
453   # fstab for a given filesystem, and use this    
454   # value of the option in another mount optio    
455   # is the first argument, the option name the    
456   # value the third. The remainder is the moun    
457   #                                               
458   # Example:                                      
459   # parse_yesno_opts_wfstab /dev/hda1 atime at    
460   #                                               
461   # If fstab contains, say, "rw" for this file    
462   # will be "defaults,atime".                     
463   parse_yesno_opts_wfstab () {                    
464         L_DEV="$1"                                
465         OPT="$2"                                  
466         DEF_OPT="$3"                              
467         shift 3                                   
468         L_OPTS="$*"                               
469         PARSEDOPTS1="$(parse_nonumber_mount_op    
470         PARSEDOPTS1="$(parse_nonumber_mount_op    
471         # Watch for a default atime in fstab      
472         FSTAB_OPTS="$(awk '$1 == "'$L_DEV'" {     
473         if echo "$FSTAB_OPTS" | grep "$OPT" >     
474                 # option specified in fstab: e    
475                 if echo "$FSTAB_OPTS" | grep "    
476                         echo "$PARSEDOPTS1,no$    
477                 else                              
478                         # no$OPT not found --     
479                         echo "$PARSEDOPTS1,$OP    
480                 fi                                
481         else                                      
482                 # option not specified in fsta    
483                 echo "$PARSEDOPTS1,$DEF_OPT"      
484         fi                                        
485   }                                               
486                                                   
487   # Find out the state of a numbered option (e    
488   # fstab for a given filesystem, and use this    
489   # value of the option in another mount optio    
490   # is the first argument, and the option name    
491   # remainder is the mount options string in w    
492   # must be done.                                 
493   #                                               
494   # Example:                                      
495   # parse_mount_opts_wfstab /dev/hda1 commit d    
496   #                                               
497   # If fstab contains, say, "commit=3,rw" for     
498   # result will be "rw,commit=3".                 
499   parse_mount_opts_wfstab () {                    
500         L_DEV="$1"                                
501         OPT="$2"                                  
502         shift 2                                   
503         L_OPTS="$*"                               
504         PARSEDOPTS1="$(parse_mount_opts $OPT $    
505         # Watch for a default commit in fstab     
506         FSTAB_OPTS="$(awk '$1 == "'$L_DEV'" {     
507         if echo "$FSTAB_OPTS" | grep "$OPT=" >    
508                 # option specified in fstab: e    
509                 echo -n "$PARSEDOPTS1,$OPT="      
510                 echo ",$FSTAB_OPTS," | sed \      
511                  -e 's/.*,'"$OPT"'=//'  \         
512                  -e 's/,.*//'                     
513         else                                      
514                 # option not specified in fsta    
515                 echo "$PARSEDOPTS1,$OPT=0"        
516         fi                                        
517   }                                               
518                                                   
519   deduce_fstype () {                              
520         MP="$1"                                   
521         # My root filesystem unfortunately has    
522         # type "unknown" in /etc/mtab. If we e    
523         # "unknown", we try to get the type fr    
524         cat /etc/fstab |                          
525         grep -v '^#' |                            
526         while read FSTAB_DEV FSTAB_MP FSTAB_FS    
527                 if [ "$FSTAB_MP" = "$MP" ]; th    
528                         echo $FSTAB_FST           
529                         exit 0                    
530                 fi                                
531         done                                      
532   }                                               
533                                                   
534   if [ $DO_REMOUNT_NOATIME -eq 1 ] ; then         
535         NOATIME_OPT=",noatime"                    
536   fi                                              
537                                                   
538   case "$1" in                                    
539         start)                                    
540                 AGE=$((100*$MAX_AGE))             
541                 XFS_AGE=$(($XFS_HZ*$MAX_AGE))     
542                 echo -n "Starting laptop_mode"    
543                                                   
544                 if [ -d /proc/sys/vm/pagebuf ]    
545                         # (For 2.4 and early 2    
546                         # This only needs to b    
547                         # laptop mode is enabl    
548                         echo $XFS_AGE > /proc/    
549                         echo $XFS_AGE > /proc/    
550                 elif [ -f /proc/sys/fs/xfs/lm_    
551                         # (A couple of early 2    
552                         # The same goes for th    
553                         echo $XFS_AGE > /proc/    
554                         echo $XFS_AGE > /proc/    
555                 elif [ -f /proc/sys/fs/xfs/age    
556                         # (2.6.6)                 
557                         # But not for these --    
558                         # operation.              
559                         echo $XFS_AGE > /proc/    
560                         echo $XFS_AGE > /proc/    
561                 elif [ -f /proc/sys/fs/xfs/age    
562                         # (2.6.7 upwards)         
563                         # And not for these ei    
564                         # not USER_HZ, so we h    
565                         echo $AGE > /proc/sys/    
566                         echo $AGE > /proc/sys/    
567                         echo 3000 > /proc/sys/    
568                 fi                                
569                                                   
570                 case "$KLEVEL" in                 
571                         "2.4")                    
572                                 echo 1            
573                                 echo "30 500 0    
574                                 ;;                
575                         "2.6")                    
576                                 echo 5            
577                                 echo "$AGE"       
578                                 echo "$AGE"       
579                                 echo "$DIRTY_R    
580                                 echo "$DIRTY_B    
581                                 ;;                
582                 esac                              
583                 if [ $DO_REMOUNTS -eq 1 ]; the    
584                         cat /etc/mtab | while     
585                                 PARSEDOPTS="$(    
586                                 if [ "$FST" =     
587                                         FST=$(    
588                                 fi                
589                                 case "$FST" in    
590                                         "ext3"    
591                                                   
592                                                   
593                                                   
594                                         "xfs")    
595                                                   
596                                                   
597                                 esac              
598                                 if [ -b $DEV ]    
599                                         blockd    
600                                 fi                
601                         done                      
602                 fi                                
603                 if [ $DO_HD -eq 1 ] ; then        
604                         for THISHD in $HD ; do    
605                                 /sbin/hdparm -    
606                                 /sbin/hdparm -    
607                         done                      
608                 fi                                
609                 if [ $DO_CPU -eq 1 -a -e /sys/    
610                         if [ $CPU_MAXFREQ = 's    
611                                 CPU_MAXFREQ=`c    
612                         fi                        
613                         echo $CPU_MAXFREQ > /s    
614                 fi                                
615                 echo "."                          
616                 ;;                                
617         stop)                                     
618                 U_AGE=$((100*$DEF_UPDATE))        
619                 B_AGE=$((100*$DEF_AGE))           
620                 echo -n "Stopping laptop_mode"    
621                 echo 0 > /proc/sys/vm/laptop_m    
622                 if [ -f /proc/sys/fs/xfs/age_b    
623                         # These need to be res    
624                         echo $(($XFS_HZ*$DEF_X    
625                         echo $(($XFS_HZ*$DEF_X    
626                 elif [ -f /proc/sys/fs/xfs/age    
627                         # These need to be res    
628                         echo $((100*$DEF_XFS_A    
629                         echo $((100*$DEF_XFS_S    
630                         echo $((100*$DEF_XFS_B    
631                 fi                                
632                 case "$KLEVEL" in                 
633                         "2.4")                    
634                                 echo "30 500 0    
635                                 ;;                
636                         "2.6")                    
637                                 echo "$U_AGE"     
638                                 echo "$B_AGE"     
639                                 echo "$DEF_DIR    
640                                 echo "$DEF_DIR    
641                                 ;;                
642                 esac                              
643                 if [ $DO_REMOUNTS -eq 1 ] ; th    
644                         cat /etc/mtab | while     
645                                 # Reset commit    
646                                 if [ "$FST" =     
647                                         FST=$(    
648                                 fi                
649                                 case "$FST" in    
650                                         "ext3"    
651                                                   
652                                                   
653                                                   
654                                                   
655                                         "xfs")    
656                                                   
657                                                   
658                                                   
659                                 esac              
660                                 if [ -b $DEV ]    
661                                         blockd    
662                                 fi                
663                         done                      
664                 fi                                
665                 if [ $DO_HD -eq 1 ] ; then        
666                         for THISHD in $HD ; do    
667                                 /sbin/hdparm -    
668                                 /sbin/hdparm -    
669                         done                      
670                 fi                                
671                 if [ $DO_CPU -eq 1 -a -e /sys/    
672                         echo `cat /sys/devices    
673                 fi                                
674                 echo "."                          
675                 ;;                                
676         *)                                        
677                 echo "Usage: $0 {start|stop}"     
678                 exit 1                            
679                 ;;                                
680                                                   
681   esac                                            
682                                                   
683   exit 0                                          
684                                                   
685                                                   
686 ACPI integration                                  
687 ----------------                                  
688                                                   
689 Dax Kelson submitted this so that the ACPI acp    
690 kick off the laptop_mode script and run hdparm    
691 automatically disables laptop mode when the ba    
692 written by Jan Topinski.                          
693                                                   
694 /etc/acpi/events/ac_adapter::                     
695                                                   
696         event=ac_adapter                          
697         action=/etc/acpi/actions/ac.sh %e         
698                                                   
699 /etc/acpi/events/battery::                        
700                                                   
701         event=battery.*                           
702         action=/etc/acpi/actions/battery.sh %e    
703                                                   
704 /etc/acpi/actions/ac.sh::                         
705                                                   
706   #!/bin/bash                                     
707                                                   
708   # ac on/offline event handler                   
709                                                   
710   status=`awk '/^state: / { print $2 }' /proc/    
711                                                   
712   case $status in                                 
713           "on-line")                              
714                   /sbin/laptop_mode stop          
715                   exit 0                          
716           ;;                                      
717           "off-line")                             
718                   /sbin/laptop_mode start         
719                   exit 0                          
720           ;;                                      
721   esac                                            
722                                                   
723                                                   
724 /etc/acpi/actions/battery.sh::                    
725                                                   
726   #! /bin/bash                                    
727                                                   
728   # Automatically disable laptop mode when the    
729                                                   
730   BATT_INFO=/proc/acpi/battery/$2/state           
731                                                   
732   if [[ -f /proc/sys/vm/laptop_mode ]]            
733   then                                            
734      LM=`cat /proc/sys/vm/laptop_mode`            
735      if [[ $LM -gt 0 ]]                           
736      then                                         
737        if [[ -f $BATT_INFO ]]                     
738        then                                       
739           # Source the config file only now th    
740           if [ -f /etc/default/laptop-mode ] ;    
741                   # Debian                        
742                   . /etc/default/laptop-mode      
743           elif [ -f /etc/sysconfig/laptop-mode    
744                   # Others                        
745                   . /etc/sysconfig/laptop-mode    
746           fi                                      
747           MINIMUM_BATTERY_MINUTES=${MINIMUM_BA    
748                                                   
749           ACTION="`cat $BATT_INFO | grep charg    
750           if [[ ACTION -eq "discharging" ]]       
751           then                                    
752              PRESENT_RATE=`cat $BATT_INFO | gr    
753              REMAINING=`cat $BATT_INFO | grep     
754           fi                                      
755           if (($REMAINING * 60 / $PRESENT_RATE    
756           then                                    
757              /sbin/laptop_mode stop               
758           fi                                      
759        else                                       
760          logger -p daemon.warning "You are usi    
761        fi                                         
762      fi                                           
763   fi                                              
764                                                   
765                                                   
766 Monitoring tool                                   
767 ---------------                                   
768                                                   
769 Bartek Kania submitted this, it can be used to    
770 spends spun up/down.  See tools/laptop/dslm/ds    
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php