Difference between revisions of "Power saving"

From ArchWiki
Jump to: navigation, search
(Divided into scripts and settings)
m (Packages: tip)
(25 intermediate revisions by 14 users not shown)
Line 1: Line 1:
 +
{{Article summary start}}
 +
{{Article summary text|Configuration and tools for saving power.}}
 +
{{Article summary heading|Related}}
 +
{{Article summary wiki|CPU Frequency Scaling}}
 +
{{Article summary wiki|Kernel modules}}
 +
{{Article summary wiki|Hybrid graphics}}
 +
{{Article summary wiki|Sysctl}}
 +
{{Article summary wiki|udev}}
 +
{{Article summary end}}
 +
 
[[Category:Power management]]
 
[[Category:Power management]]
 
This article covers the configuration needed to turn on power saving features. Almost all of the features listed here are worth using whether or not the computer is on AC or battery power. Most have negligible performance impact and are just not enabled by default because of commonly broken hardware/drivers. Reducing power usage means reducing heat, which can even lead to higher performance on a modern Intel or AMD CPU, thanks to [[Wikipedia:Intel Turbo Boost|dynamic overclocking]].
 
This article covers the configuration needed to turn on power saving features. Almost all of the features listed here are worth using whether or not the computer is on AC or battery power. Most have negligible performance impact and are just not enabled by default because of commonly broken hardware/drivers. Reducing power usage means reducing heat, which can even lead to higher performance on a modern Intel or AMD CPU, thanks to [[Wikipedia:Intel Turbo Boost|dynamic overclocking]].
  
=Ready to run scripts=
+
== Configuration ==
There are already a couple of scripts and tools which make use of the various settings described in the next section. These are notably:
+
  
* [[Tlp]]
+
If you would like to create your own scripts and power saving settings such as by udev rules you can take the following settings as a reference.
* [[Powerdown]]
+
* {{AUR|powerconf}}
+
* [[Laptop Mode Tools]]
+
  
If you do not want to take care of the settings by yourself it is recommended to use these tools. But be aware of running only '''one''' of these tools to avoid possible conflicts as they all work more or less similar.
+
=== Audio ===
  
=Custom settings=
+
By default, audio power saving is turned off by most drivers.  It can be enabled by setting the {{ic|power_save}} parameter; a time (in seconds) to go into idle mode. To idle the audio card after one second, create
If you would like to create your own scripts and power saving settings such as by Udev rules you can take the following settings as a reference.
+
  
==Audio==
+
{{hc|/etc/modprobe.d/audio_powersave.conf|2=options snd_hda_intel power_save=1}}
  
By default, audio power saving is turned off by most drivers. It can be enabled by setting the power_save parameter to a time (in seconds) to go in idle.
+
for Intel, or use
  
{{Note|Toggling the audio card's power state can cause a popping sound or noticeable latency on some broken hardware.}}
+
  options snd_ac97_codec power_save=1
  
;Intel
+
for ac97.
  
{{hc|/etc/modprobe.d/audio_power_save.conf|2=options snd_hda_intel power_save=1}}
+
{{Note|Toggling the audio card's power state can cause a popping sound or noticeable latency on some broken hardware.}}
 
+
;ac97
+
 
+
{{hc|/etc/modprobe.d/audio_power_save.conf|2=options snd_ac97_codec power_save=1}}
+
  
==Active State Power Management==
+
=== Active state power management ===
  
 
To verify that [[Wikipedia:Active State Power Management|ASPM]] is enabled:
 
To verify that [[Wikipedia:Active State Power Management|ASPM]] is enabled:
Line 35: Line 36:
 
{{hc|$ cat /sys/module/pcie_aspm/parameters/policy|[default] performance powersave}}
 
{{hc|$ cat /sys/module/pcie_aspm/parameters/policy|[default] performance powersave}}
  
Either {{ic|[default]}} or {{ic|[powersave]}} means you do not need to force it on.
+
Either {{ic|[default]}} or {{ic|[powersave]}} means you do not need to force it on. Otherwise, it's either unsupported or broken on your hardware, or has to be forced on with {{ic|1=pcie_aspm=force}} on the [[kernel line]].
  
Otherwise, it's either unsupported/broken on your hardware, or has to be forced on with {{ic|1=pcie_aspm=force}} on the [[kernel line]].
+
{{Warning|
 +
* Forcing on ASPM can cause a freeze/panic, so make sure you have a way to undo the option if it doesn't work.
 +
* On systems that don't support it forcing on ASPM can even increase power consumption.}}
  
{{Warning|Forcing on ASPM can cause a freeze/panic, so make sure you have a way to undo the option if it doesn't work.}}
+
=== Backlight ===
{{Warning|On systems that don't support it forcing on ASPM can even increase power consumption.}}
+
 
+
== Backlight ==
+
  
 
When system starts, screen backlight is set to maximum by default. This can be fixed by specifying backlight level in the following udev rule:
 
When system starts, screen backlight is set to maximum by default. This can be fixed by specifying backlight level in the following udev rule:
Line 51: Line 51:
 
</nowiki>}}
 
</nowiki>}}
  
== Bluetooth ==
+
See [[Backlight]] for more information.
 +
 
 +
=== Bluetooth ===
 +
 
 
{{expansion|reason=The device should likely be disabled with hciconfig first.}}
 
{{expansion|reason=The device should likely be disabled with hciconfig first.}}
 
[[Kernel_modules#Blacklisting|Blacklist]] the {{ic|hci_usb}} module if the driver is loaded automatically.
 
[[Kernel_modules#Blacklisting|Blacklist]] the {{ic|hci_usb}} module if the driver is loaded automatically.
Line 66: Line 69:
 
</nowiki>}}
 
</nowiki>}}
  
== Web-Camera ==
+
=== Web-Camera ===
 +
 
 
If you won't use integrated web camera then [[Kernel_modules#Blacklisting|blacklist]] the {{ic|uvcvideo}} module.
 
If you won't use integrated web camera then [[Kernel_modules#Blacklisting|blacklist]] the {{ic|uvcvideo}} module.
  
==Disabling NMI watchdog==
+
=== Kernel parameters ===
The [[Wikipedia:Non-maskable interrupt|NMI]] watchdog is a debugging feature to catch hardware hangs and cause a kernel panic. On some systems it can generate a lot of interrupts, causing a noticeable increase in power usage.
+
  
{{hc|/etc/sysctl.d/disable_watchdog.conf|2=kernel.nmi_watchdog = 0}}
+
This section uses configs in {{ic|/etc/sysctl.d/}}, which is ''"a drop-in directory for kernel sysctl parameters, extending what you can already do with /etc/sysctl.conf."''  See [http://0pointer.de/blog/projects/the-new-configuration-files The New Configuration Files] and more specifically [http://0pointer.de/public/systemd-man/sysctl.d.html systemd's sysctl.d man page] for more information.
  
or add {{ic|1=nmi_watchdog=0}} as a [[kernel parameter]] to disable it completely from early boot.
+
==== Disabling NMI watchdog ====
  
==Disabling Wake-on-LAN==
+
The [[Wikipedia:Non-maskable interrupt|NMI]] watchdog is a debugging feature to catch hardware hangs and cause a kernel panic. On some systems it can generate a lot of interrupts, causing a noticeable increase in power usage.
  
[[Wikipedia:Wake-on-LAN|Wake-on-LAN]] can be a useful feature, but if you're not making use of it then it's simply draining extra power waiting for a magic packet while in suspend.
+
{{hc|/etc/sysctl.d/disable_watchdog.conf|2=kernel.nmi_watchdog = 0}}
  
Disabling for all Ethernet interfaces:
+
or add {{ic|1=nmi_watchdog=0}} to the [[kernel parameter|kernel line]] to disable it completely from early boot.
  
{{hc|/etc/udev/rules.d/disable_wol.rules|2=ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*" RUN+="/usr/sbin/ethtool -s %k wol d"}}
+
==== Writeback Time ====
 +
Increasing the VM dirty writeback time can help to aggregate I/O together - reducing disk writes, and decreasing power usage:
  
You can use multiple names in the matches; for example, {{ic|1=KERNEL=="lan0&#124;eth*"}}
+
  vm.dirty_writeback_centisecs = 1500
  
{{Note|This should be combined with [[udev#Network device|static naming]] of devices, the {{ic|eth*}} names are not static.}}
+
To do the same for journal commits with ext4 and some other filesystems, use {{ic|1=commit=15}} as a parameter in [[fstab]] or with the {{ic|rootflags}} [[kernel parameter]].
  
== PCI Runtime Power Management ==
+
==== Laptop Mode ====
  
{{hc|/etc/udev/rules.d/pci_pm.rules|2=ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"}}
+
See the [https://www.kernel.org/doc/Documentation/laptops/laptop-mode.txt kernel documentation] on the laptop mode 'knob.' ''"A sensible value for the knob is 5 seconds."''
  
==Wireless power saving==
+
  vm.laptop_mode = 5
  
Enabling for a specific interface:
+
=== Network interfaces ===
  
{{Note|This should be combined with [[udev#Network device|static naming]] of devices, the eth* names are not static.}}
+
[[Wikipedia:Wake-on-LAN|Wake-on-LAN]] can be a useful feature, but if you're not making use of it then it's simply draining extra power waiting for a magic packet while in suspend. Disabling for all Ethernet interfaces:
  
{{hc|/etc/udev/rules.d/wlan0_power_save.rules|2=ACTION=="add", SUBSYSTEM=="net", KERNEL=="wifi0" RUN+="/usr/sbin/iw dev wifi0 set power_save on"}}
+
{{hc|/etc/udev/rules.d/70-disable_wol.rules|2=ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*" RUN+="/usr/bin/ethtool -s %k wol d"}}
  
Enabling for all interfaces:
+
To enable powersaving on all wireless interfaces:
  
{{hc|/etc/udev/rules.d/wifi_power_save.rules|2=ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*" RUN+="/usr/sbin/iw dev %k set power_save on"}}
+
{{hc|/etc/udev/rules.d/70-wifi-powersave.rules|2=ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*" RUN+="/usr/bin/iw dev %k set power_save on"}}
  
== Writeback Time ==
+
In these examples, {{ic|%k}} is a specifier for the kernel name of the matched device.  For example, if it finds that the rule is applicable to {{ic|wlan0}}, the {{ic|%k}} specifier will be replaced with {{ic|wlan0}}. To apply the rules to only a particular interface, just replace the pattern {{ic|eth*}} and specifier {{ic|%k}} with the desired interface name. For more information, see [http://www.reactivated.net/writing_udev_rules.html Writing udev rules].
Increasing the VM dirty writeback time can help to aggregate I/O together - reducing disk writes, and decreasing power usage:
+
  
{{hc|/etc/sysctl.d/dirty_writeback.conf|2=vm.dirty_writeback_centisecs = 1500}}
+
In this case, the name of the configuration file is important. Due to the introduction of [[Network_Configuration#Device_names|persistent device names]] via {{ic|80-net-name-slot.rules}} in systemd v197, it is important that the network powersave rules are named lexicographically before {{ic|80-net-name-slot.rules}}, so that they are applied before the devices are named e.g. {{ic|enp2s0}}.
  
To do the same for journal commits with ext4 and some other filesystems, use {{ic|1=commit=15}} as a parameter in [[fstab]] or with the {{ic|rootflags}} [[kernel parameter]].
+
=== PCI Runtime Power Management ===
  
== Laptop Mode ==
+
{{hc|/etc/udev/rules.d/pci_pm.rules|2=ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"}}
 
+
 
{{hc|/etc/sysctl.d/laptop_mode.conf|2=vm.laptop_mode = 5}}
+
=== SATA Active Link Power Management ===
  
== SATA Active Link Powermanagement ==
 
 
{{Note|This adds latency when accessing a drive that has been idle, so it's one of the few settings that may be worth toggling based on whether you're on AC power.}}
 
{{Note|This adds latency when accessing a drive that has been idle, so it's one of the few settings that may be worth toggling based on whether you're on AC power.}}
 
  {{hc|/etc/udev/rules.d/hd_power_save.rules|2=SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="min_power"}}
 
  {{hc|/etc/udev/rules.d/hd_power_save.rules|2=SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="min_power"}}
  
== USB Autosuspend ==
+
=== USB Autosuspend ===
 +
 
 
To enable USB autosuspend after 2 seconds of inactivity:
 
To enable USB autosuspend after 2 seconds of inactivity:
  {{hc|/etc/udev/rules.d/usb_power_save.rules|2=ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control" ATTR{power/control}="auto"
+
  {{hc|/etc/udev/rules.d/usb_power_save.rules|<nowiki>
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend" ATTR{power/autosuspend}="2"}}
+
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control" ATTR{power/control}="auto"
 +
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend" ATTR{power/autosuspend}="2"
 +
</nowiki>}}
 +
 
 +
Other option is to use modprobe:
 +
{{hc|/etc/modprobe.d/modprobe.conf|<nowiki>
 +
options usbcore autosuspend=2
 +
</nowiki>}}
 +
 
 +
=== Device Power Management ===
  
== Device Power Management ==
 
 
{{accuracy|reason=Should be done with a udev rule.}}
 
{{accuracy|reason=Should be done with a udev rule.}}
  
Line 130: Line 141:
 
  echo auto | tee /sys/bus/spi/devices/*/power/control > /dev/null
 
  echo auto | tee /sys/bus/spi/devices/*/power/control > /dev/null
  
== View Power Setings ==
+
== Tools and scripts ==
This function shows various power settings.  Note you either must be root or you must have sudo.
+
 
 +
=== Packages ===
 +
 
 +
There are many scripts and tools which make use of the various settings described in the previous sections. These are notably:
 +
 
 +
* [[TLP]]
 +
* [[Powerdown]]
 +
* {{AUR|powerconf}}
 +
* {{AUR|ftw-git}}
 +
* [[Laptop Mode Tools]]
 +
* [[pm-utils]]
 +
 
 +
If you do not want to take care of the settings by yourself it is recommended to use these tools. But be aware of running only '''one''' of these tools to avoid possible conflicts as they all work more or less similar.
 +
 
 +
{{Tip|Have a look at the [[:Category:Power management|power management category]] to get an overview on what power management options exists in Archlinux.}}
 +
 
 +
=== Using a script and an udev rule ===
 +
 
 +
Since systemd users can suspend and hibernate through {{ic|systemctl suspend}} or {{ic|systemctl hibernate}} and handle acpi events with {{ic|/etc/systemd/logind.conf}}, it might be interesting to remove pm-utils and acpid. Now, there's just one thing systemd can't do (at this time of writing): powermanagement, depending on whether the system is running on AC or battery. To fill this gap, one can create a single udev rule that launches a script when the laptop is unplugged and plugged:
 +
{{hc|/etc/udev/rules.d/powersave|2=<nowiki>
 +
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/path/to/your/script true"
 +
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/path/to/your/script false"
 +
</nowiki>}}
 +
{{Note|One can use the same script that pm-powersave uses. You just have to make it executable and place it somewhere else (for example, /usr/bin).}}
 +
Examples of powersave scripts can be found here: [https://bbs.archlinux.org/viewtopic.php?pid=1046075#p1046075] (or in aur: {{AUR|powerdown}}), here: [https://github.com/Unia/powersave] and there: [https://aur.archlinux.org/packages/powerconf].
 +
 
 +
The above udev rule should work as expected, but if your power settings aren't updated after a suspend or hibernate cycle, you should add a script in {{ic|/usr/lib/systemd/system-sleep/}} with the following contents:
 +
{{hc|/usr/lib/systemd/system-sleep/00powersave|<nowiki>
 +
#!/bin/sh
 +
 
 +
case $1 in
 +
    pre) /path/to/your/script false ;;
 +
    post)     
 +
if cat /sys/class/power_supply/AC0/online | grep 0 > /dev/null 2>&1
 +
then
 +
    /path/to/your/script true
 +
else
 +
    /path/to/your/script false
 +
fi
 +
    ;;
 +
esac'
 +
exit 0
 +
</nowiki>}}
 +
 
 +
Don't forget to make it executable!
 +
{{Note|Be aware that AC0 may be different for your laptop, change it if that is the case.}}
 +
 
 +
Now you don't need pm-utils anymore. Depending on your configuration, it may be a dependency of some other package. If you wish to remove it anyway, run {{ic|pacman -Rdd pm-utils}}.
 +
 
 +
=== Print power settings ===
 +
 
 +
This script prints power settings and a variety of other properties for USB and PCI devices.  Note that root permissions are needed to see all settings.
 +
 
 +
{{bc|<nowiki>#!/bin/bash
 +
 
 +
for i in $(find /sys/devices -name "bMaxPower")
 +
do
 +
busdir=${i%/*}
 +
busnum=$(<$busdir/busnum)
 +
devnum=$(<$busdir/devnum)
 +
title=$(lsusb -s $busnum:$devnum)
  
{{bc|<nowiki>function aa_power_settings ()
+
printf "\n\n+++ %s\n  -%s\n" "$title" "$busdir"
{
+
  sudo bash -c '
+
    for i in `find /sys/devices -name "bMaxPower"`;
+
    do
+
        for ii in `find $i -type f`;
+
        do
+
            bd=`dirname $ii`;
+
            busnum=`cat $bd/busnum`;
+
            devnum=`cat $bd/devnum`;
+
            title=`lsusb -s $busnum:$devnum`;
+
            echo -e "\n\n+++ $title\n  -$bd\n -$ii";
+
            for ff in `find $bd/power -type f ! -empty 2>/dev/null`;
+
            do
+
                v=`cat $ff 2>/dev/null|tr -d "\n"`;
+
                [[ ${#v} -gt 0 ]] && echo -e " `basename $ff`=$v";
+
                v=;
+
            done | sort -g;
+
        done;
+
    done;
+
    echo -e "\n\n\n+++ Kernel Modules\n";
+
    for m in `command lspci -k|sed -n "/in use:/s,^.*: ,,p"|sort -u`;
+
    do
+
        echo "+ $m";
+
        systool -v -m $m 2> /dev/null | sed -n "/Parameters:/,/^$/p";
+
    done
+
  ';
+
}</nowiki>}}
+
  
== See also ==
+
for ff in $(find $busdir/power -type f ! -empty 2>/dev/null)
 +
do
 +
v=$(cat $ff 2>/dev/null|tr -d "\n")
 +
[[ ${#v} -gt 0 ]] && echo -e " ${ff##*/}=$v";
 +
v=;
 +
done | sort -g;
 +
done;
  
* [[CPU Frequency Scaling]]
+
printf "\n\n\n+++ %s\n" "Kernel Modules"
 +
for mod in $(lspci -k | sed -n '/in use:/s,^.*: ,,p' | sort -u)
 +
do
 +
echo "+ $mod";
 +
systool -v -m $mod 2> /dev/null | sed -n "/Parameters:/,/^$/p";
 +
done</nowiki>}}

Revision as of 15:00, 26 June 2013

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end This article covers the configuration needed to turn on power saving features. Almost all of the features listed here are worth using whether or not the computer is on AC or battery power. Most have negligible performance impact and are just not enabled by default because of commonly broken hardware/drivers. Reducing power usage means reducing heat, which can even lead to higher performance on a modern Intel or AMD CPU, thanks to dynamic overclocking.

Configuration

If you would like to create your own scripts and power saving settings such as by udev rules you can take the following settings as a reference.

Audio

By default, audio power saving is turned off by most drivers. It can be enabled by setting the power_save parameter; a time (in seconds) to go into idle mode. To idle the audio card after one second, create

/etc/modprobe.d/audio_powersave.conf
options snd_hda_intel power_save=1

for Intel, or use

 options snd_ac97_codec power_save=1

for ac97.

Note: Toggling the audio card's power state can cause a popping sound or noticeable latency on some broken hardware.

Active state power management

To verify that ASPM is enabled:

$ cat /sys/module/pcie_aspm/parameters/policy
[default] performance powersave

Either [default] or [powersave] means you do not need to force it on. Otherwise, it's either unsupported or broken on your hardware, or has to be forced on with pcie_aspm=force on the kernel line.

Warning:
  • Forcing on ASPM can cause a freeze/panic, so make sure you have a way to undo the option if it doesn't work.
  • On systems that don't support it forcing on ASPM can even increase power consumption.

Backlight

When system starts, screen backlight is set to maximum by default. This can be fixed by specifying backlight level in the following udev rule:

/etc/udev/rules.d/backlight.rules
## SET BACKLIGHT
SUBSYSTEM=="backlight", ACTION=="add", KERNEL=="acpi_video0", ATTR{brightness}="1"

See Backlight for more information.

Bluetooth

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: The device should likely be disabled with hciconfig first. (Discuss in Talk:Power saving#)
Blacklist the hci_usb module if the driver is loaded automatically.

Alternatively, blacklist the btusb and bluetooth modules.

Another variant is to rfkill it:

# rfkill block bluetooth

Or with udev rule:

/etc/udev/rules.d/bt.rules
## DISABLE BLUETOOTH
SUBSYSTEM=="rfkill", ATTR{type}=="bluetooth", ATTR{state}="0"

Web-Camera

If you won't use integrated web camera then blacklist the uvcvideo module.

Kernel parameters

This section uses configs in /etc/sysctl.d/, which is "a drop-in directory for kernel sysctl parameters, extending what you can already do with /etc/sysctl.conf." See The New Configuration Files and more specifically systemd's sysctl.d man page for more information.

Disabling NMI watchdog

The NMI watchdog is a debugging feature to catch hardware hangs and cause a kernel panic. On some systems it can generate a lot of interrupts, causing a noticeable increase in power usage.

/etc/sysctl.d/disable_watchdog.conf
kernel.nmi_watchdog = 0

or add nmi_watchdog=0 to the kernel line to disable it completely from early boot.

Writeback Time

Increasing the VM dirty writeback time can help to aggregate I/O together - reducing disk writes, and decreasing power usage:

 vm.dirty_writeback_centisecs = 1500

To do the same for journal commits with ext4 and some other filesystems, use commit=15 as a parameter in fstab or with the rootflags kernel parameter.

Laptop Mode

See the kernel documentation on the laptop mode 'knob.' "A sensible value for the knob is 5 seconds."

 vm.laptop_mode = 5

Network interfaces

Wake-on-LAN can be a useful feature, but if you're not making use of it then it's simply draining extra power waiting for a magic packet while in suspend. Disabling for all Ethernet interfaces:

/etc/udev/rules.d/70-disable_wol.rules
ACTION=="add", SUBSYSTEM=="net", KERNEL=="eth*" RUN+="/usr/bin/ethtool -s %k wol d"

To enable powersaving on all wireless interfaces:

/etc/udev/rules.d/70-wifi-powersave.rules
ACTION=="add", SUBSYSTEM=="net", KERNEL=="wlan*" RUN+="/usr/bin/iw dev %k set power_save on"

In these examples, %k is a specifier for the kernel name of the matched device. For example, if it finds that the rule is applicable to wlan0, the %k specifier will be replaced with wlan0. To apply the rules to only a particular interface, just replace the pattern eth* and specifier %k with the desired interface name. For more information, see Writing udev rules.

In this case, the name of the configuration file is important. Due to the introduction of persistent device names via 80-net-name-slot.rules in systemd v197, it is important that the network powersave rules are named lexicographically before 80-net-name-slot.rules, so that they are applied before the devices are named e.g. enp2s0.

PCI Runtime Power Management

/etc/udev/rules.d/pci_pm.rules
ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"

SATA Active Link Power Management

Note: This adds latency when accessing a drive that has been idle, so it's one of the few settings that may be worth toggling based on whether you're on AC power.
/etc/udev/rules.d/hd_power_save.rules
SUBSYSTEM=="scsi_host", KERNEL=="host*", ATTR{link_power_management_policy}="min_power"

USB Autosuspend

To enable USB autosuspend after 2 seconds of inactivity:

/etc/udev/rules.d/usb_power_save.rules
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/control" ATTR{power/control}="auto"
ACTION=="add", SUBSYSTEM=="usb", TEST=="power/autosuspend" ATTR{power/autosuspend}="2"

Other option is to use modprobe:

/etc/modprobe.d/modprobe.conf
options usbcore autosuspend=2

Device Power Management

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Should be done with a udev rule. (Discuss in Talk:Power saving#)
echo auto | tee /sys/bus/i2c/devices/*/power/control > /dev/null
echo auto | tee /sys/bus/spi/devices/*/power/control > /dev/null

Tools and scripts

Packages

There are many scripts and tools which make use of the various settings described in the previous sections. These are notably:

If you do not want to take care of the settings by yourself it is recommended to use these tools. But be aware of running only one of these tools to avoid possible conflicts as they all work more or less similar.

Tip: Have a look at the power management category to get an overview on what power management options exists in Archlinux.

Using a script and an udev rule

Since systemd users can suspend and hibernate through systemctl suspend or systemctl hibernate and handle acpi events with /etc/systemd/logind.conf, it might be interesting to remove pm-utils and acpid. Now, there's just one thing systemd can't do (at this time of writing): powermanagement, depending on whether the system is running on AC or battery. To fill this gap, one can create a single udev rule that launches a script when the laptop is unplugged and plugged:

/etc/udev/rules.d/powersave
SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/path/to/your/script true"
SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/path/to/your/script false"
Note: One can use the same script that pm-powersave uses. You just have to make it executable and place it somewhere else (for example, /usr/bin).

Examples of powersave scripts can be found here: [1] (or in aur: powerdownAUR), here: [2] and there: [3].

The above udev rule should work as expected, but if your power settings aren't updated after a suspend or hibernate cycle, you should add a script in /usr/lib/systemd/system-sleep/ with the following contents:

/usr/lib/systemd/system-sleep/00powersave
#!/bin/sh

case $1 in
    pre) /path/to/your/script false ;;
    post)       
	if cat /sys/class/power_supply/AC0/online | grep 0 > /dev/null 2>&1
	then
    		/path/to/your/script true	
	else
    		/path/to/your/script false
	fi
    ;;
esac'
exit 0

Don't forget to make it executable!

Note: Be aware that AC0 may be different for your laptop, change it if that is the case.

Now you don't need pm-utils anymore. Depending on your configuration, it may be a dependency of some other package. If you wish to remove it anyway, run pacman -Rdd pm-utils.

Print power settings

This script prints power settings and a variety of other properties for USB and PCI devices. Note that root permissions are needed to see all settings.

#!/bin/bash

for i in $(find /sys/devices -name "bMaxPower")
do
	busdir=${i%/*}
	busnum=$(<$busdir/busnum)
	devnum=$(<$busdir/devnum)
	title=$(lsusb -s $busnum:$devnum)

	printf "\n\n+++ %s\n  -%s\n" "$title" "$busdir"

	for ff in $(find $busdir/power -type f ! -empty 2>/dev/null)
	do
		v=$(cat $ff 2>/dev/null|tr -d "\n")
		[[ ${#v} -gt 0 ]] && echo -e " ${ff##*/}=$v";
		v=;
	done | sort -g;
done;

printf "\n\n\n+++ %s\n" "Kernel Modules"
for mod in $(lspci -k | sed -n '/in use:/s,^.*: ,,p' | sort -u)
do
	echo "+ $mod";
	systool -v -m $mod 2> /dev/null | sed -n "/Parameters:/,/^$/p";
done