Page 1 of 1

laptop_mode on Mint 12

Posted: Sun May 20, 2012 8:12 am
by hankwang
I have trouble getting laptop_mode to run properly on Mint 12. I hope someone can help me here.

I'm running kernel 3.0.0-12, laptop-mode-tools 1.57-1ubuntu1. I have traced the major processes that do regular writes (smbd, cups, network-manager) and made them write to /var/run (tmpfs filesystem) rather than to the main filesystem. I have also modified /usr/sbin/laptop_mode to recognize a 3.0 kernel. According to syslog, laptop_mode responds to changes in AC power. However, /proc/sys/vm/{laptop_mode,dirty_writeback_centisecs} are not updated, which causes frequent spin-ups in case of write activity. Regardless of AC/battery state, these files are:

/proc/sys/vm/dirty_writeback_centisecs - 500
/proc/sys/vm/laptop_mode - 0

Example test script (polls the spin-down state with two-second intervals, and writes a file half-way)

Code: Select all

$ cat /proc/sys/vm/laptop_mode ; for i in 1 2 3; do hdparm -C /dev/sda | grep state; sleep 2; done; echo > /tmp/lmtest ; echo;  for i in 1 2 3 4 5; do hdparm -C /dev/sda | grep state; sleep 2; done
0 ## laptop_mode
 drive state is:  standby
 drive state is:  standby
 drive state is:  standby
## here, a file in /tmp is written
 drive state is:  active/idle
 drive state is:  active/idle
 drive state is:  active/idle
 drive state is:  active/idle
 drive state is:  standby

$ mount
/dev/sda8 on / type ext4 (rw,noatime,errors=remount-ro,commit=360,commit=360)
Relevant laptop-mode.conf settings:

Code: Select all

ENABLE_LAPTOP_MODE_TOOLS=1
ENABLE_LAPTOP_MODE_ON_BATTERY=1
ENABLE_LAPTOP_MODE_ON_AC=1
ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED=1
LM_BATT_MAX_LOST_WORK_SECONDS=600
LM_AC_MAX_LOST_WORK_SECONDS=360
(I'm trying to turn an old netbook into a low-power and flexible NAS, but given the amount of time that it has cost me so far, I might better have bought one...)

Re: laptop_mode on Mint 12

Posted: Sun May 20, 2012 8:48 am
by hankwang
Somehow, forcing myself to write down the problem often gives me inspiration to the solution...

The problem was: there were kernel version checks elsewhere (in /usr/share/laptop-mode-tools/modules/laptop-mode ) as well. I solved it by changing /usr/sbin/laptop_mode as follows:

case "$KLEVEL" in
"2.4" ) ;;
"2.6" ) ;;
3.* ) KLEVEL=2.6 ;; ### this line is added!

I saw that this problem is fixed somewhere upstream (laptop mode 1.58), but it is not available as update for Mint 12.

By the way, as reference for anyone else with similar issues: I did this to prevent frequent disk writes:

Add this to /etc/rc.local:

Code: Select all

mkdir /var/run/NetworkManager
Do this from the command line

Code: Select all

sudo bash
cd /var/lib
mv NetworkManager NetworkManager.old
mkdir /var/run/NetworkManager
ln -s ../run/NetworkManager
rm /var/run/cups/subscriptions.conf
ln -s /var/run/cups/subscriptions.conf /etc/cups/subscriptions.conf
exit