Power saving trick for laptops - BETA

Using applications, configuring, problems
Post Reply
Message
Author
Shel
Posts: 103
Joined: Sat 11 Apr 2009, 17:33
Location: Seattle, WA, USA, or Southern France

Power saving trick for laptops - BETA

#1 Post by Shel »

Folks-

Linux has a long-standing problem with running down the battery of certain laptop machines when the machine is "off."

This affects many Toshibas, but has been reported with other brands. It affects many, maybe all, recent versions of Linux, Puppy and Ubuntu included. It certainly affected Puppy 4.3.1 on my Toshiba Portege R100.

After some investigation, I discovered that the machine's internal Ethernet card was still running after Puppy shut down the machine. Since "Wake-on-LAN" was disabled in the machines BIOS, I thought this a bit bizarre.

Solving the problem turned out to be fairly simple; unload the driver module (e100 for the R100) before shutting down.

To see if this problem affects your computer, check the lights on either the machine's Ethernet port or the hub/switch/router it is plugged into. If the lights are on after Puppy shuts down the box, you have the problem.

The following script attempts to unload all the networking modules:

Code: Select all

#!/bin/sh
#
# Unload the Ethernet drivers on shutdown to prevent battery drain.
# STH 28 May 2010, after the rc.pcmcia script by BK.
# For Puppy Linux 4.3.1

case "$1" in
	start)		# Puppy loads the drivers at bootup, we don't have to!
		;;
	stop)
	    echo -n "Shutting down Ethernet services: " > /dev/console
		for i in `/sbin/lsmod | cut -d' ' -f1` ; do
			if grep -q "^$i " /etc/networkmodules; then
				/sbin/modprobe -r "$i" && echo -n "$i " > /dev/console
			fi
		done
		echo > /dev/console
                sleep 2 # take this out once testing complete
		;;
	restart)
		;;
esac

# END
Drop this script into /etc/init.d (for Puppy 4.3.1) or whatever directory has its scripts run on shutdown, make it executable, and watch the screen on your next shutdown. If you see a quick message about unloading, and if a repeat of the port test shows the port is now inactive when the machine has been shut down, you're on velvet.

-Shel

User avatar
abushcrafter
Posts: 1418
Joined: Fri 30 Oct 2009, 16:57
Location: England
Contact:

#2 Post by abushcrafter »

I have put the contents of your post in Shell script form. So others don't have too when they use it and want the info in the script.

Code: Select all

#!/bin/sh
#Puppy Linux Discussion Forum :: View topic - Power saving trick for laptops - BETA - http://www.murga-linux.com/puppy/viewtopic.php?t=56238
#Post subject:  Power saving trick for laptops - BETA
#Subject description: If your laptop battery runs down while the machine is "off"
#
#Linux has a long-standing problem with running down the battery of certain laptop machines when the machine is "off."
#
#This affects many Toshibas, but has been reported with other brands. It affects many, maybe all, recent versions of Linux, Puppy and Ubuntu included. It certainly affected Puppy 4.3.1 on my Toshiba Portege R100.
#
#After some investigation, I discovered that the machine's internal Ethernet card was still running after Puppy shut down the machine. Since "Wake-on-LAN" was disabled in the machines BIOS, I thought this a bit bizarre.
#
#Solving the problem turned out to be fairly simple; unload the driver module (e100 for the R100) before shutting down.
#
#To see if this problem affects your computer, check the lights on either the machine's Ethernet port or the hub/switch/router it is plugged into. If the lights are on after Puppy shuts down the box, you have the problem.
#
#The following script attempts to unload all the networking modules: 
#
# Unload the Ethernet drivers on shutdown to prevent battery drain.
# STH 28 May 2010, after the rc.pcmcia script by BK.
# For Puppy Linux 4.3.1

case "$1" in
   start)      # Puppy loads the drivers at bootup, we don't have to!
      ;;
   stop)
       echo -n "Shutting down Ethernet services: " > /dev/console
      for i in `/sbin/lsmod | cut -d' ' -f1` ; do
         if grep -q "^$i " /etc/networkmodules; then
            /sbin/modprobe -r "$i" && echo -n "$i " > /dev/console
         fi
      done
      echo > /dev/console
                sleep 2 # take this out once testing complete
      ;;
   restart)
      ;;
esac

# END 

#Drop this script into /etc/init.d (for Puppy 4.3.1) or whatever directory has its scripts run on shutdown, make it executable, and watch the screen on your next shutdown. If you see a quick message about unloading, and if a repeat of the port test shows the port is now inactive when the machine has been shut down, you're on velvet.
#
#-Shel

Flapdoodle
Posts: 32
Joined: Thu 03 Jul 2008, 15:55

Re: Power saving trick for laptops - BETA

#3 Post by Flapdoodle »

If your laptop battery runs down while the machine is "off"
Is this a problem whether LAN is used or not?

In other words, is the LAN turned on by probing when Puppy boot then left on?

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#4 Post by BarryK »

Very interesting, shel thanks for that.
I have incorporated it into /etc/rc.d/rc.shutdown in Woof.
[url]https://bkhome.org/news/[/url]

Shel
Posts: 103
Joined: Sat 11 Apr 2009, 17:33
Location: Seattle, WA, USA, or Southern France

Re: Power saving trick for laptops - BETA

#5 Post by Shel »

Flapdoodle wrote:Is this a problem whether LAN is used or not?
It is on my laptop.
In other words, is the LAN turned on by probing when Puppy boot then left on?
I think it's turned on by loading the driver module (e100 in my case).

-Shel

Shel
Posts: 103
Joined: Sat 11 Apr 2009, 17:33
Location: Seattle, WA, USA, or Southern France

#6 Post by Shel »

BarryK wrote:Very interesting, shel thanks for that.
I have incorporated it into /etc/rc.d/rc.shutdown in Woof.
My pleasure, sir!

-Shel

ferikenagy
Posts: 53
Joined: Mon 20 Nov 2006, 08:26
Contact:

wake on lan

#7 Post by ferikenagy »

before unloading network module it should be made an test that Wake On Lan (WOL) is disabled. by command:


# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Link partner advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Link partner advertised pause frame use: No
Link partner advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: yes
#
if " Wake-on: d " , then WOL is d-isabled and the network module should be unload from memory, network card pushed down, but instead of 'd' parameter is anything else from "Supports Wake-on:pumbg" (g,p,s,u,b) putting down the network card should be skipped because it means the user want to use the WOL .
At hardware reset the WOL is disabled so "Wake-on: d " parameter is guaranteed.

in almost modern laptops this function (WOL) is not available when is running from battery, only from the main power supply because the hardware periferials (network card, USB...) are unpowered in battery mode.

Shel
Posts: 103
Joined: Sat 11 Apr 2009, 17:33
Location: Seattle, WA, USA, or Southern France

Re: wake on lan

#8 Post by Shel »

ferikenagy wrote:before unloading network module it should be made an test that Wake On Lan (WOL) is disabled. by command:

# ethtool eth0.
In my experience, ethtool is not a reliable indicator of WOL status.

On my Toshiba Portege R100, WOL is reported by the BIOS as disabled, but ethtool reports it as "g" or enabled.

I discovered this as part of my investigation into the battery drain problem. I had already checked the BIOS settings for likely candidates, but when I discovered that the Ethernet port was active when the machine was off, I double-checked. Yep, WOL disabled in BIOS, but reported as active by ethtool.

Just FWIW, I was professionally involved in IT since the days it was known as "DP"; I've never had occasion to use WOL, nor, in fact, seen it used on any site where I've worked. I'd say the benefit of turning off the card will accrue to many more users than will the inconvenience of disabling WOL.

You are correct, however, in that unloading the module will hose WOL, and it's good to have that brought up. I expect that the Puppy user base won't care, and that anyone who does will be clever enough to fix the shutdown script.

-Shel

ferikenagy
Posts: 53
Joined: Mon 20 Nov 2006, 08:26
Contact:

unloading eth module onpower off with WOL active

#9 Post by ferikenagy »

thanks for your answer. The fact is am using Wake On Lan on puppy,in a very simple way, one of my puppy computer is the LAN printer server too (CUPS does a good job as LAN printer server ), and my brother who is in different location wakes up the computer before printing, and after some inactivity time it automaticaly shut down.
I can imagine other uses of WOL, for example if puppy computer is the gateway for internet in LAN, and after inactivity it power off, but any physical lan activity could power up the puppy computer, or it could be power up from the internet if puppy has an ftp or http server on it , it could be one of my future project to test, so the aproach is to stay green to turn of computer when not needed , that why WOL is for!. So even if you had right that nobody use it (exept solely) me, in the future it should be use to save energy to be more enviroment friendly. I presume it could be an good question what will decide the future of WOL in puppy: some quinky defective bios or hardware example like in your computer or on of the future philosophy of saveing green the planet?
Maybe we can find an middle aproach for this problem. I have not tested but the WOL is implemented at hardware level on the ethernet card, and it wakes the computer on an hardware intrerupt signal, the computer is powered down, so if the WOL is activated and computer is power down it should not neded the module. The problem is I supose to unload the module without afecting WOL state of the card and without making before power of an software disable of the card: "ifconfig eth0 down". Maybe it should work.
So maybe it worth to make a litle more efort not to simply eradicate the WOL from puppy, and try to unload the module on defective computer...

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#10 Post by 8-bit »

I have a Toshiba Satellite L550 series laptop and I have had no problem with the lan, but if I have a USB digital mouse plugged in when I shut down the PC, sometimes the led in the mouse fails to shut off.
But it is NOT just a linux problem as I have had it happen with Win 7 64bit also.

Shel
Posts: 103
Joined: Sat 11 Apr 2009, 17:33
Location: Seattle, WA, USA, or Southern France

#11 Post by Shel »

Maybe it's keeping the USB ports "hot" so you can use them to recharge your cellphone or something.

I wish that sort of stuff were more configurable!

-Shel

Cranky-9
Posts: 1
Joined: Mon 05 Sep 2011, 08:58
Contact:

#12 Post by Cranky-9 »

Great program which I use on my laptop with Arch Linux.
But I wonder where “However, laptop mode is disabled by default in Ubuntu Edgy (6.10)

Post Reply