You are not logged in.

#1 2008-02-17 11:43:52

bavardage
Member
Registered: 2008-02-17
Posts: 160

[Solved] Warn on low battery/halt

Hi,
This is my third day of arch, and on two occasions so-far I have forgotten that my laptop is unplugged and so has run out of battery and turned off. I thought that maybe it was time to do something about it.

How do I go about calling a script (i.e. to halt or to play a sound or something) when the battery is low. (1)Would /etc/acpi/handler.sh be the right place to put things in? (have got the laptop dimming when ac power is removed, and the screen turning off when lip is closed)

From perusing the forums it seems someone mentioned laptop tools, however from reading documentation on it, in various places, it scares me a little. Things about killing HDs. (2) Can I be sure that I have disabled any RAM-killing features? Also, from looking in /etc/laptop-mode/laptop-mode.conf it seems that it only supports hibernate on low battery, however this is another thing I have yet to set-up. (3)Can hibernating be done with a swapfile smaller than my ram (RAM is 1.5gb, swap 1gb)? If no, (6) can I change my swapfile size w/o losing data on my /home partition (the partition preceding the swapfile)?

Thanks if you managed to get through the jumble above. I fail epicly at forum posts. Never can seem to make them totally comprehensible.

Edit: If relevant: Laptop is HP 530, running on Openbox.

Last edited by bavardage (2008-02-18 15:29:01)

Offline

#2 2008-02-17 15:21:05

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: [Solved] Warn on low battery/halt

I don't know about shutting down the laptop on low battery but I'm sure you can resize your swap. Just use GParted LiveCD.


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#3 2008-02-17 15:39:35

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [Solved] Warn on low battery/halt

Personally I use laptop-mode-tools for that (it has a config option that lets you call a particular command when battery is low)...  You could also use the script from this page on gentoo wiki: http://gentoo-wiki.com/HOWTO_Software_S … ery_is_low -- just put it in rc.local.  I've tried it before and I can attest to the fact that it works.

EDIT: If you use something like uswsusp and enable compression you shouldn't have problems with hibernating even if your swap is less than your total memory.

Last edited by fwojciec (2008-02-17 15:41:18)

Offline

#4 2008-02-17 17:13:08

bavardage
Member
Registered: 2008-02-17
Posts: 160

Re: [Solved] Warn on low battery/halt

Thankyou so much. I now have hibernate working like a charm. This is why I love arch linux - useful advice in 4 hours tongue

What do I need to watch out for then in the laptop mode conf to ensure nothing is done to my HD. Currently my conf looks like:

sorry for huge.

###############################################################################
#
# Configuration for Laptop Mode Tools
# -----------------------------------
#
# There is a "system" to the configuration setting names:
#    CONTROL_something=0/1   Determines whether Laptop Mode Tools controls 
#                            something
#    LM_something=value      Value of "something" when laptop mode is active
#    NOLM_something=value    Value of "something" when laptop mode is NOT
#                            active
#    AC_something=value      Value of "something" when the computer is running
#                            on AC power
#    BATT_something=value    Value of "something when the computer is running
#                            on battery power
#
# There can be combinations of LM_/NOLM_ and AC_/BATT_ prefixes, but the
# available prefixes are different for each setting. The available ones are 
# documented in the manual page, laptop-mode.conf(8). If there is no LM_/
# NOLM_ in a setting name, then the value is used independently of laptop
# mode state, and similarly, if there is no AC_/BATT_, then the value is used
# independently of power state.
#
# Some options only work on ACPI systems. They are marked ACPI-ONLY.
#
# Note that this configuration file is a fragment of bash shell script: you
# can use all the features of the bash scripting language to achieve your
# desired configuration.
#
# 
# IMPORTANT: Laptop Mode Tools modules have separate configuration files, that
# can be found in /etc/laptop-mode/conf.d. Please look through these
# configuration files as well!
#
###############################################################################



###############################################################################
# Configuration debugging
# -----------------------
###############################################################################


#
# Set this to 1 if you want to see a lot of information when you start/stop 
# laptop_mode.
#
VERBOSE_OUTPUT=0



###############################################################################
# When to enable laptop mode
# --------------------------
#
# "Laptop mode" is the mode in which laptop mode tools makes the computer
# consume less power. This includes the kernel "laptop_mode" feature, which
# allows your hard drives to spin down, as well as various other settings which
# can be tweaked by laptop mode tools. You can enable or disable all of these
# settings using the CONTROL_... options further down in this config file.
###############################################################################


#
# Enable laptop mode when on battery power.
#
ENABLE_LAPTOP_MODE_ON_BATTERY=1


#
# Enable laptop mode when on AC power.
#
ENABLE_LAPTOP_MODE_ON_AC=0


#
# Enable laptop mode when the laptop's lid is closed, even when we're on AC
# power? (ACPI-ONLY)
#
ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED=0



###############################################################################
# When to enable data loss sensitive features
# -------------------------------------------
#
# When data loss sensitive features are disabled, laptop mode tools acts as if
# laptop mode were disabled, for those features only.
#
# Data loss sensitive features include:
# - laptop_mode (i.e., delayed writes)
# - hard drive write cache
#
# All of the options that follow can be set to 0 in order to prevent laptop
# mode tools from using them to stop data loss sensitive features. Use this
# when you have a battery that reports the wrong information, that confuses
# laptop mode tools.
#
# Disabling data loss sensitive features is ACPI-ONLY.
###############################################################################


#
# Disable all data loss sensitive features when the battery level (in % of the
# battery capacity) reaches this value.
#
MINIMUM_BATTERY_CHARGE_PERCENT=3


#
# Disable data loss sensitive features when the battery reports its state
# as "critical".
#
DISABLE_LAPTOP_MODE_ON_CRITICAL_BATTERY_LEVEL=1


###############################################################################
# Controlled hard drives and partitions
# -------------------------------------
#
# For spinning down your hard drives, laptop mode will remount file systems and
# adjust hard drive spindown timeouts. These parameters specify which
# devices and partitions are affected by laptop mode.
###############################################################################


#
# The drives that laptop mode controls.
# Separate them by a space, e.g. HD="/dev/hda /dev/hdb". The default is a
# wildcard, which will get you all your IDE and SCSI/SATA drives.
#
HD="/dev/[hs]d[abcdefgh]"


#
# The partitions (or mount points) that laptop mode controls.
# Separate the values by spaces. Use "auto" to indicate all partitions on drives
# listed in HD. You can add things to "auto", e.g. "auto /dev/hdc3". You can
# also specify mount points, e.g. "/mnt/data".
#
PARTITIONS="auto /dev/mapper/*"


#
# If this is enabled, laptop mode tools will assume that SCSI drives are
# really SATA drives that only _look_ like SCSI drives, and will use hdparm
# to control them. Set this to 0 if you have /dev/sd devices and you want
# laptop mode tools to use the "sdparm" command to control them. 
#
ASSUME_SCSI_IS_SATA=1


###############################################################################
# Hard drive behaviour settings
# -----------------------------
#
# These settings specify how laptop mode tools will adjust the various
# parameters of your hard drives and file systems.
###############################################################################


#
# Maximum time, in seconds, of work that you are prepared to lose when your
# system crashes or power runs out. This is the maximum time that Laptop Mode
# will keep unsaved data waiting in memory before spinning up your hard drive.
#
LM_BATT_MAX_LOST_WORK_SECONDS=600
LM_AC_MAX_LOST_WORK_SECONDS=360


#
# Should laptop mode tools control readahead?
#
CONTROL_READAHEAD=0


#
# Read-ahead, in kilobytes. You can spin down the disk while playing MP3/OGG
# by setting the disk readahead to a reasonable size, e.g. 3072 (3 MB).
# Effectively, the disk will read a complete MP3 at once, and will then spin 
# down while the MP3/OGG is playing. Don't set this too high, because the 
# readahead is applied to _all_ files that are read from disk.
#
LM_READAHEAD=3072
NOLM_READAHEAD=128


#
# Should laptop mode tools add the "noatime" option to the mount options when 
# laptop mode is enabled?
#
CONTROL_NOATIME=0


#
# Should laptop mode tools control the hard drive idle timeout settings?
#
CONTROL_HD_IDLE_TIMEOUT=0


#
# Idle timeout values. (hdparm -S)
# Default is 2 hours on AC (NOLM_HD_IDLE_TIMEOUT_SECONDS=7200) and 20 seconds
# for battery and for AC with laptop mode on.
#
LM_AC_HD_IDLE_TIMEOUT_SECONDS=20
LM_BATT_HD_IDLE_TIMEOUT_SECONDS=20
NOLM_HD_IDLE_TIMEOUT_SECONDS=7200


#
# Should laptop mode tools control the hard drive power management settings?
#
CONTROL_HD_POWERMGMT=0


#
# Power management for HD (hdparm -B values)
#
BATT_HD_POWERMGMT=1
LM_AC_HD_POWERMGMT=254
NOLM_AC_HD_POWERMGMT=254


#
# Should laptop mode tools control the hard drive write cache settings?
#
CONTROL_HD_WRITECACHE=0


#
# Write cache settings for HD (hdparm -W values)
#
NOLM_AC_HD_WRITECACHE=1
NOLM_BATT_HD_WRITECACHE=0
LM_HD_WRITECACHE=0



###############################################################################
# CPU frequency scaling and throttling
# ------------------------------------
#
# Laptop mode tools can automatically adjust your kernel CPU frequency
# settings. This includes upper and lower limits and scaling governors.
# There is also support for CPU throttling, on systems that don't support
# frequency scaling.
#
# This feature only works on 2.6 kernels.
###############################################################################


#
# Should laptop mode tools control the maximum CPU frequency?
#
CONTROL_CPU_FREQUENCY=0


#
# Legal values are "slowest" for the slowest speed that your
# CPU is able to operate at, "fastest" for the fastest speed,
# "medium" for some value in the middle, or any value listed in
# /sys/devices/system/cpu/cpu*/cpufreq/scaling_available_frequencies.
# The "governor" can be any governor installed on your system, this usually
# includes "ondemand", "conservative", and "performance". The
# "IGNORE_NICE_LOAD" setting specifies that background programs that have
# a low priority ("nice level") should not cause the CPU frequency to
# be increased. (You generally want this to be enabled in battery mode.)
#
BATT_CPU_MAXFREQ=medium
BATT_CPU_MINFREQ=slowest
BATT_CPU_GOVERNOR=ondemand
BATT_CPU_IGNORE_NICE_LOAD=1
LM_AC_CPU_MAXFREQ=fastest
LM_AC_CPU_MINFREQ=slowest
LM_AC_CPU_GOVERNOR=ondemand
LM_AC_CPU_IGNORE_NICE_LOAD=1
NOLM_AC_CPU_MAXFREQ=fastest
NOLM_AC_CPU_MINFREQ=slowest
NOLM_AC_CPU_GOVERNOR=performance
NOLM_AC_CPU_IGNORE_NICE_LOAD=0


#
# Should laptop mode tools control the CPU throttling? This is only useful
# on processors that don't have frequency scaling.
# (Only works when you have /proc/acpi/processor/CPU*/throttling.)
#
CONTROL_CPU_THROTTLING=0


#
# Legal values are "maximum" for the maximum (slowest) throttling level,
# "minimum" for minimum (fastest) throttling level, "medium" for a value
# somewhere in the middle (this is usually 50% for P4s), or any value listed
# in /proc/acpi/processor/CPU*/throttling. Be careful when using "maximum":
# this may be _very_ slow (in fact, with P4s it slows down the processor
# by a factor 8).
#
BATT_CPU_THROTTLING=medium
LM_AC_CPU_THROTTLING=medium
NOLM_AC_CPU_THROTTLING=minimum



###############################################################################
# Syslog configuration control
# ----------------------------
# 
# Syslog daemons have a tendency to sync their log files when entries are
# written to them. This causes disks to spin up, which is not very nice when
# you're trying to save power. The syslog.conf can be tweaked to *not* sync
# a given file, by prepending the log file name with a dash, like this:
#
#     mail.*        -/var/log/mail/mail.log
#
# Using the following options, you can let laptop mode switch between
# different syslog configurations depending on whether you are working on
# battery or on AC power. To set this up, start by configuring these options
# for your syslog daemon, and then run lm-syslog-setup to create the various
# files. Then edit the laptop mode-specific syslog configuration files to
# remove the syncs only when laptop mode is active.
###############################################################################


#
# Should laptop mode tools control which syslog.conf should be used?
#
CONTROL_SYSLOG_CONF=0


#
# Laptop mode tools controls syslog.conf by replacing /etc/syslog.conf (or
# whatever you specify in SYSLOG_CONF) by a link to the files configured here.
# NOTE: these files are NOT created by default, and if they do not
# exist this feature will not work. You can run the script
# /usr/sbin/lm-syslog-setup to set things up.
#
LM_AC_SYSLOG_CONF=/etc/syslog-on-ac-with-lm.conf
NOLM_AC_SYSLOG_CONF=/etc/syslog-on-ac-without-lm.conf
BATT_SYSLOG_CONF=/etc/syslog-on-battery.conf


#
# Signal this program when syslog.conf has been replaced.
#
SYSLOG_CONF_SIGNAL_PROGRAM=syslogd


#
# This is the syslog configuration file that should be replaced by a link to
# the other files.
#
SYSLOG_CONF=/etc/syslog.conf



###############################################################################
# X display settings
# ------------------
#
# Using these settings, you can let laptop mode tools control the X display
# standby timeouts.
#
# This requires that you have installed the "xset" utility. It is part of the
# X.org server distribution and included in the package xorg-server-utils.
#
# The X settings are not automatically applied on login, and this is
# impossible fix for the user, since laptop mode tools must operate as root.
# Therefore, it is recommended to add the following line to /etc/X11/Xsession
# as well:
#
#   /usr/sbin/laptop_mode force
#
###############################################################################


#
# Should laptop mode tools control DPMS standby settings for X displays?
#
CONTROL_DPMS_STANDBY=0


#
# These settings specify the standby timeout for the X display,
# in seconds. The suspend and poweroff timeouts are somewhat
# larger values derived from these values.
#
BATT_DPMS_STANDBY=300
LM_AC_DPMS_STANDBY=1200
NOLM_AC_DPMS_STANDBY=1200



###############################################################################
# Terminal settings
# -----------------
#
# Using these settings, you can let laptop mode tools control the terminal
# blanking timeouts. This only works for linux virtual consoles.
#
###############################################################################


#
# Should laptop mode tools control terminal blanking settings?
#
CONTROL_TERMINAL=0


#
# Terminal device files that should be affected. (One terminal is enough, this
# affects all consoles. )
#
TERMINALS="/dev/tty1"


#
# These settings specify the blanking and powerdown timeouts. Note that
# the powerdown timeout is counted from the moment the screen is blanked,
# i.e. BLANK_MINUTES=2 and POWERDOWN_MINUTES=5 means the screen powers
# down after 7 minutes of inactivity. The range for all these settings is
# 1 to 60 minutes, or 0 to disable.
#
BATT_TERMINAL_BLANK_MINUTES=1
BATT_TERMINAL_POWERDOWN_MINUTES=2
LM_AC_TERMINAL_BLANK_MINUTES=10
LM_AC_TERMINAL_POWERDOWN_MINUTES=10
NOLM_AC_TERMINAL_BLANK_MINUTES=10
NOLM_AC_TERMINAL_POWERDOWN_MINUTES=50


###############################################################################
# LCD brightness settings
# -----------------------
#
# Using these settings, you can make laptop mode tools automatically adjust
# your LCD's brightness settings. The settings are extremely simple -- they
# only allow for the execution of a command, nothing more. The reason for this
# is that LCD brightness settings are very different between laptop vendors.
#
# Suggestions for commands:
#
#  * If your system has the file "/proc/acpi/video/VID/LCD/brightness" (VID may
#    be VID1 or similar), use this file as BRIGHTNESS_OUTPUT, and use
#    the command "echo <value>". The possible values can be listed using the
#    command:
#
#       cat /proc/acpi/video/VID/LCD/brightness
#
#  * If you have a file /sys/class/backlight/.../brightness, then you can use
#    that file as BRIGHTNESS_OUTPUT, and the command "echo <value>".
#
#    As far as I understand it the values are between 0 and
#    the value contained in the file /sys/class/backlight/.../max_brightness.
#
#  * For Toshiba laptops, use the command "toshset" with the -lcd or -inten
#    command. Read the toshset(1) manual page for more information on the
#    parameters for this command. If you use this command, set
#    BRIGHTNESS_OUTPUT to "/dev/null".
#
###############################################################################


#
# Should laptop mode tools control LCD brightness?
#
CONTROL_BRIGHTNESS=0


#
# Commands to execute to set the brightness on your LCD
#
BATT_BRIGHTNESS_COMMAND="echo [value]"
LM_AC_BRIGHTNESS_COMMAND="echo [value]"
NOLM_AC_BRIGHTNESS_COMMAND="echo [value]"
BRIGHTNESS_OUTPUT="/proc/acpi/video/VID/LCD/brightness"


###############################################################################
# Auto-hibernation settings
# -------------------------
#
# Using these settings, you can make laptop mode tools automatically put your
# computer into hibernation when the battery level goes critically low.
#
# This feature only works on ACPI, and only works on computers whose batteries
# give off battery events often enough.
###############################################################################


#
# Should laptop mode tools perform auto-hibernation?
#
ENABLE_AUTO_HIBERNATION=1


#
# The hibernation command that is to be executed when auto-hibernation
# is triggered.
#
HIBERNATE_COMMAND=/usr/sbin/hibernate


#
# Auto-hibernation battery level threshold, in percentage of the battery's
# total capacity.
#
AUTO_HIBERNATION_BATTERY_CHARGE_PERCENT=2


#
# Enable this to auto-hibernate if the battery reports that its level is
# "critical".
#
AUTO_HIBERNATION_ON_CRITICAL_BATTERY_LEVEL=1



###############################################################################
# Start/Stop Programs settings
# ----------------------------
#
# Laptop mode tools can automatically start and stop programs when entering
# various power modes. Put scripts accepting "start" and "stop" parameters
# in the directories /etc/laptop-mode/batt-stop, batt-start, lm-ac-stop,
# lm-ac-start, nolm-ac-stop and nolm-ac-start. Laptop mode will call the
# scripts in a state-"stop" directory with the "stop" parameter when entering
# the state in question, and it will call the same scripts with the "start"
# parameter when leaving the state. Scripts in a state-"start" directory are
# called with the "start" parameter when the specified state is entered, and
# with the "stop" parameter when the specified state is left.
###############################################################################


#
# Should laptop mode start and stop programs? 
#
CONTROL_START_STOP=0



###############################################################################
# Settings you probably don't want to touch
...

Offline

#5 2008-02-17 17:40:49

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [Solved] Warn on low battery/halt

This is what I have in my laptop-mode.conf

# Should laptop mode tools control the hard drive power management settings?
#
CONTROL_HD_POWERMGMT=1
#
# Power management for HD (hdparm -B values)
#
BATT_HD_POWERMGMT=254
LM_AC_HD_POWERMGMT=254
NOLM_AC_HD_POWERMGMT=255

This in my rc.local:

# Turn hard drive spin downs off
hdparm -B 254 /dev/sda > /dev/null
hdparm -S 241 /dev/sda > /dev/null

I also noticed that suspend and hibernate reset hdparm settings so I use scripts as wrappers for the suspend and hibernate command and add the commands from rc.local to each script (after suspend/hibernate command).

This effectively stops the hard drive spin downs on my laptop.  You might want to play with the hdparm values -- it seems to work slightly differently for different hard drive types.

Offline

#6 2008-02-17 21:34:40

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: [Solved] Warn on low battery/halt

Correct me if I'm wrong, but doesn't using disk power management shorten the disks lifespan ? It can only spin so many times....


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#7 2008-02-17 22:03:09

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [Solved] Warn on low battery/halt

moljac024 wrote:

Correct me if I'm wrong, but doesn't using disk power management shorten the disks lifespan ? It can only spin so many times....

It is debatable -- but I disable it anyways (this is what the procedure described in my previous post accomplishes).
If you don't set anything explicitly your laptop hard drive is spinning down by default, and usually quite aggressively.  This is why enabling HD power management in laptop mode tools can actually help -- you let it "control" hd power management and you use that control to disable it.
You can read more about the debate here: http://bbs.archlinux.org/viewtopic.php?id=39258

Offline

#8 2008-02-17 22:13:57

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: [Solved] Warn on low battery/halt

Well, I always disable disk power management, lifespan debate aside, I just can't stand the clicking sound...

EDIT: I just noticed you rc.local

I just add this to mine:

hdparm -B 255 /dev/sda

Isn't that enough ?

Last edited by moljac024 (2008-02-17 22:15:40)


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#9 2008-02-17 22:23:47

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [Solved] Warn on low battery/halt

This tends to work differently on different hardware (it seems to depend on hd firmware, to be specific).  I noticed that on my computer the hdparm settings are reset on every suspend/hibernate cycle, for example.  As long as you don't hear the clicking sounds you're probably ok, though.  You can also check if your hard drive spins down or not using smartmontools tools (see the link in my previous post for more info).

Last edited by fwojciec (2008-02-17 22:24:13)

Offline

#10 2008-02-17 22:41:58

bavardage
Member
Registered: 2008-02-17
Posts: 160

Re: [Solved] Warn on low battery/halt

Actually thinking about it, it would probably be much better to just use a good ol-fashioned script, such as the one in the gentoo wiki. Does laptop mode have any other power-saving benefits, other than HD stuff, and I'd rather not risk anything like that.

Offline

#11 2008-02-17 22:54:20

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [Solved] Warn on low battery/halt

In my opinion laptop-mode-tools is the single best powersaving tool in linux -- read through the comments in the laptop-mode-tools.conf file; you should be able to control (meaning enable/disable/configure) pretty much all powersaving features of your laptop with this script.  I've been using it for a long time and I have no complaints about it. 

If you don't want laptop-mode to control the powersaving features of your hd then just tell it not to (CONTROL_HD_POWERMGMT=0) -- although you can also use laptop-mode to override the default spin down settings of your hd (yes, your hd most likely spins down by default; this is how its designed, and this is what its firmware tells it to do) -- in order to disable spin downs completely.

If you use another powersaving tool then you might just as well use the script from the gentoo wiki.

Last edited by fwojciec (2008-02-17 22:56:53)

Offline

#12 2008-02-17 22:57:00

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: [Solved] Warn on low battery/halt

Well, I don't hear clicking sounds.


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#13 2008-02-18 10:09:50

bavardage
Member
Registered: 2008-02-17
Posts: 160

Re: [Solved] Warn on low battery/halt

Only powermanagement that I currently use is cpu-scaling. Hmm I think I'll give laptop-mode a go, assuming that the defaults for laptop mode are safe-ish?

Edit:
How do I actually get laptop mode going? I have installed it (ofc) and edited the /etc/laptop-mode/laptop-mode.conf, but when calling /usr/sbin/laptop_mode, no matter if on ac or battery, I get "Laptop mode disabled, not active [unchanged]"

Edit:
Do I just start the laptop-mode daemon in rc.conf, then call /usr/sbin/laptop_mode auto when something happens?

Last edited by bavardage (2008-02-18 10:50:04)

Offline

#14 2008-02-18 14:52:24

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [Solved] Warn on low battery/halt

bavardage wrote:

Only powermanagement that I currently use is cpu-scaling. Hmm I think I'll give laptop-mode a go, assuming that the defaults for laptop mode are safe-ish?

Edit:
How do I actually get laptop mode going? I have installed it (ofc) and edited the /etc/laptop-mode/laptop-mode.conf, but when calling /usr/sbin/laptop_mode, no matter if on ac or battery, I get "Laptop mode disabled, not active [unchanged]"

Edit:
Do I just start the laptop-mode daemon in rc.conf, then call /usr/sbin/laptop_mode auto when something happens?

Just add "laptop-mode" to the DAEMONS array in rc.conf.  You can also start it manually with /etc/rc.d/laptop-mode start.

Offline

#15 2008-02-18 15:28:42

bavardage
Member
Registered: 2008-02-17
Posts: 160

Re: [Solved] Warn on low battery/halt

Thank you all. I think that's everything solved tongue

Offline

#16 2008-12-23 11:43:15

Barghest
Member
From: Hanau/Germany
Registered: 2008-01-03
Posts: 563

Re: [Solved] Warn on low battery/halt

fwojciec wrote:

This is what I have in my laptop-mode.conf

# Should laptop mode tools control the hard drive power management settings?
#
CONTROL_HD_POWERMGMT=1
#
# Power management for HD (hdparm -B values)
#
BATT_HD_POWERMGMT=254
LM_AC_HD_POWERMGMT=254
NOLM_AC_HD_POWERMGMT=255

This in my rc.local:

# Turn hard drive spin downs off
hdparm -B 254 /dev/sda > /dev/null
hdparm -S 241 /dev/sda > /dev/null

I also noticed that suspend and hibernate reset hdparm settings so I use scripts as wrappers for the suspend and hibernate command and add the commands from rc.local to each script (after suspend/hibernate command).

This effectively stops the hard drive spin downs on my laptop.  You might want to play with the hdparm values -- it seems to work slightly differently for different hard drive types.

Sorry for digging out this thread but I wanted to know why one has to adjust hdparm twice. Once in laptop mode tolls and once in rc.local.

Doesn't laptop mode alone set hdparm correctly?

Another question is about the "risk" of the option -S. I've read many threads about -B (I use hdparm -B 254 /dev/sda > /dev/null in my rc.local as well) but don't know how -S can affect the HDs lifetime.

Thanks!

Last edited by Barghest (2008-12-23 11:43:34)

Offline

#17 2008-12-23 12:32:33

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [Solved] Warn on low battery/halt

That's an awfully old thread...

I don't remember why I had these hdparm commands in rc.local -- you're right, it doesn't make a whole lot of sense. 
Also, since then I'd changed my mind about hd spin downs -- I do want the hard drive to spin down, the whole laptop is set up to use the hard drive as little as possible in order to save battery and reduce noise.

Now I just use laptop-mode-tools with, pretty much, default settings as far as hard drive management is concerned.

Sorry, I don't know the answer to your hdparm question.

Offline

#18 2008-12-23 15:31:19

Barghest
Member
From: Hanau/Germany
Registered: 2008-01-03
Posts: 563

Re: [Solved] Warn on low battery/halt

fwojciec wrote:

I'd changed my mind about hd spin downs -- I do want the hard drive to spin down, the whole laptop is set up to use the hard drive as little as possible in order to save battery and reduce noise.

Now I just use laptop-mode-tools with, pretty much, default settings as far as hard drive management is concerned.

Can you please specify what you did exactly to reduce power comsumption and what you use for HD management? Do you have experiences about the amount of power that can be saved?

I'm also a bit irritated about the "right" settings concerning spin-downs and life reduction of the HD (I allready read the thread about this topic).

\edit: Are the settings of laptop mode set correctly after resume or do you have to use the script mentioned in the wiki?

Thanks

Last edited by Barghest (2008-12-23 16:59:08)

Offline

#19 2008-12-24 00:24:38

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: [Solved] Warn on low battery/halt

The two indispensable tools for power saving, for me, are powertop and laptop-mode-tools.  This is all I use.  Powertop is for monitoring power consumption, laptop mode is for managing the settings.  http://www.lesswatts.org/ is also a good website with some great power saving tips.

On my laptop (Toshiba Satellite A35) enabling laptop-mode-tools with spindown delay set to 20 seconds reduces power draw by about 0.7W compared to having the hard drive running constantly.  It's not a great amount, but it helps.  I mostly like it because it has a side effect of making the laptop completely silent and in many cases I can run what I need from memory for long periods of time -- provided I'm doing something simple like editing a document, or having a document opened for reference.

I'm also using preload and a have a bunch of dirs (/tmp, /var/log) mounted as tmpfs.

As far as resuming is concerned -- I've configured pm-utils to restart laptop-mode-tools after system wakes up from suspend/hibernate.  Just a simple script in /etc/pm/sleep.d.

Offline

#20 2009-06-13 13:57:50

leo2501
Member
From: Buenos Aires, Argentina
Registered: 2007-07-07
Posts: 658

Re: [Solved] Warn on low battery/halt

sorry if it was already answered, but i can't find the answer to the "How do I go about calling a script (i.e. to halt or to play a sound or something) when the battery is low" question...

I already installed and configured laptop-mode-tools, but i want to set up that at 10%-20% battery it plays a sound, and at 5%-10% it shutdown the computer, i dont want it to suspend

Another question, if i run powertop, and follow the instructions the keybindings says, will they remain when you reboot?

thankyou all smile


Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

Offline

Board footer

Powered by FluxBB