Setting up for laptops

This page should contain links to pages needed for configuring a laptop for the best experience. Setting up a laptop is in many ways the same as setting up a desktop. However, there are a few key differences. When setting up a laptop with Arch Linux, the following points should be taken into consideration:

#Power Management Power Management for laptops refers to optimizing the system to last as long as possible on a single battery charge. This can be accomplished by a variety of tweaks.

#Suspend and Hibernate : the operating system can be manually suspended either to memory or to disk, allowing for an (almost) complete shutdown of other hardware.

Hard drive spindown : the system can be configured to automatically turn off the hard disk after a specified interval of inactivity.

Screen shut off : the laptop screen can be configured to automatically turn off after a specified interval of inactivity (not just blanked with a screensaver but completely shut off).

CPU frequency scaling : the processor(s) can be configured to automatically step down to a lower frequency at lower loads.

All of these points are important to take into consideration when getting a laptop set up the way you like. Fortunately, Arch Linux provides all the tools and programs necessary to take complete control of your laptop. These programs and utilities are highlighted below, with appropriate tips tutorials.

Power management

Power management is very important for anyone who wishes to make good use of their battery capacity. The following tools and programs help to increase battery life and keep your laptop cool and quiet.

Battery state

Udev events

The factual accuracy of this article or section is disputed.

Reason: On my system, battery-level-changed events are not sent. Reminder: describe way to check if the events are sent. (Discuss in Talk:Laptop#)

Upon change battery sends events which can be handled by udev. Example of how it could be used is presented below.

Low charge action

By default, the system won't do anything if your laptop's battery is going to discharge. In order not to lose all unsaved work this example udev rule could be used (if your battery sends uevent when it charges/discharges by 1%):

Likewise, the rule can be customized to perform other action on different status.

Utilities

Battery state can be read using ACPI utilities from the terminal. ACPI command line utilities are provided via the acpi package. A simple battery monitor that sits in the system tray is batterymon-cloneAUR which can be found in the AUR.

batti is a simple battery monitor for the system tray, similar to batterymon-clone. Unlike the latter batti uses UPower, and if that is missing DeviceKit.

Suspend and Hibernate

Manually suspending the operating system, either to memory (standby) or to disk (hibernate) sometimes provides the most efficient way to optimize battery life, depending on the usage pattern of the laptop. While there is relatively straightforward support in the linux kernel to support these operations, typically some adjustments have to be made before initiating these operations (typically due to problematic drivers, modules or hardware). The following tools provide wrappers around the kernel interfaces to suspend/resume :

Automatic tweaks for battery life

As opposed to manually initiated actions like suspend/hibernate, a number of tweaks can be made to prolong the battery life of the laptop under low/idle usage.

CPU Frequency Scaling is a technology used primarily by notebooks which enables the OS to scale the CPU frequency up or down, depending on the current system load and/or power scheme.

Laptop Mode Tools provides a comprehensive suite of tools to tweak a large number of power saving settings through well documented configuration files.

Powertop is a handy utility from Intel that displays which hardware/processes are using the most power on your system, and provides instructions on how to stop or remove power-wasting services. Works great for mobile Intel CPUs; provides the current CPU state and suggestions for power saving. Also works on AMD systems, but does not provide as much information about the CPU state.

TLP is a power management tool that provides all the latest tweaks to save battery power without the need for elaborated configuration (nonetheless it is highly configurable).

The following options are specific to certain laptop types:

Lapsus is a set of programs providing easy access to many features of various laptops. It currently supports most features provided by asus-laptop kernel module from ACPI4Asus project, such as additional LEDs, hotkeys, backlight control etc. It also has support for some IBM laptops features provided by IBM ThinkPad ACPI Extras Driver and NVRAM device.

Battery tweaks for ThinkPads can be found in TLP and the tp_smapi article.

PCI-e ASPM

On some laptops, powertop suggests enabling the CONFIG_PCIEASPM kernel option. It can be found under Bus options (PCI etc.) > PCI Express ASPM support. This option is marked as experimental in the current kernel (2.6.35) and allows the PCI-e links to enter a power saving state.

According to [1], this option might degrade performance a bit, but on an Acer 3820TG laptop, it can reduce power consumption by about one third or even more.

More experience with this setting would be appreciated, so please share them here!

It seems like the option is going to be enabled by default in kernel 2.6.36; if so, the information here will be obsolete soon. However, if your system should be able to make use of this power management feature but you are receiving messages like like the following (check /var/log/everything.log*):

disabling ASPM on pre-1.1 PCI-e device. You can enable it with 'pcie_aspm=force'

then add pcie_aspm=force to your kernel command line.

Granola

Granola is a daemon that monitors the cpu usage and uses the cpufreq-userspace module to lessen power usage without any noticeable difference in performance.
To use it, first install from the AUR:[2], the default settings will work for most setups.
You will need to load the cpufreq_userspace module, as well as the cpufreq scaling governor for your CPU at startup.
Create two files like the following ones to start modules at boot:

/etc/modules-load.d/cpufreq_userspace.conf

cpufreq_userspace

/etc/modules-load.d/<choosen governor>.conf

<choosen governor>

and reboot.

To test if it worked, run:

cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq

or, if you have cpufreq-utils installed:

cpufreq-info

and check that the cpu frequency is below maximum.

Wireless

When working on your notebook/laptop without wireless access, here is a little script for your system startup that turns off your WLAN-Hardware to keep it from wasting power searching for an Access Point:

Start the script according to your DE/WM options by sleep xx && /path/to/script depending on how long it usually takes to connect to your Access Point, 60 seconds are a good default value. It checks if you're connected, turning off the device if not. # iwconfig wlp2s0 txpower on brings it back up, as well as a reboot.

Tip: It may also be prudent to prevent your wireless interface from starting at boot if it is not used often.

Disk-related tweaks

Disable file access time: every time you access (read) a file the filesystem writes an access time to the file metadata. You can disable this on individual files by using the chattr command, or you can enable it on an entire disk by setting the noatime option in your fstab, as follows:

Note: Disabling atime causes troubles with mutt and other applications that make use of file timestamps. Consider compromising between performance and compatibility by using the default mount option relatime instead, or look into mutt work-around for noatime.

Note: laptop-mode-tools automatically rewrites these values based on the values LM_BATT_MAX_LOST_WORK_SECONDS, LM_AC_MAX_LOST_WORK_SECONDS (both multiplied by 100) resp. LM_SECONDS_BEFORE_SYNC, which are set in /etc/laptop-mode/laptop-mode.conf. However, that only happens if the three "Enable laptop mode" variables in the same file are set accordingly — left to 0, it resets the values to kernel defaults (500 / 0) for the corresponding scenario regardless of /etc/sysctl.conf.

You can also set it to 255 to completely disable spinning down. You may wish to set a lower value if you move your laptop around as lower values park the heads more often and reduce the chance of damage to your hard disk while it is being moved. If you do not move your laptop at all when you are using it, then 255 or 254 is probably best. If you do, then you might want to try a lower value. A value like 128 might be a good middle-ground.

and run chmod +x /etc/pm/sleep.d/50-hdparm_pm to make sure it resets after suspend. Again, you can change the value 254 as you see fit.

Now the APM level should be set for your hard drive.

For some laptops, the option -S to hdparm can also be relevant (sets the spindown time for the drive). Note that all these options can also be configured using the laptop-mode tools. This will allow you to set a high value when on AC and a lower value when you are running on battery power.

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:

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: [3] (or in aur: powerdownAUR), here: [4] and there: [5].

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:

Screen brightness

Touchpad

To get your touchpad working properly, see the Touchpad Synaptics page. Note that your laptop may have an ALPS touchpad (such as the DELL Inspiron 6000), and not a Synaptics touchpad. In either case, see the link above.

Hard disk shock protection

There are several laptops from different vendors featuring shock protection capabilities. As manufacturers have refused to support open source development of the required software components so far, Linux support for shock protection varies considerably between different hardware implementations.

Currently, two projects, named HDAPS and hpfall, support this kind of protection.
HDAPS is for IBM/Lenovo Thinkpads and hpfall for HP/Compaq laptops

Network time syncing

For a laptop, it may be a good idea to use Chrony as an alternative to NTPd to sync your clock over the network. Chrony is designed to work well even on systems with no permanent network connection (such as laptops), and is capable of much faster time synchronisation than standard ntp. Chrony has several advantages when used in systems running on virtual machines, such as a larger range for frequency correction to help correct quickly drifting clocks, and better response to rapid changes in the clock frequency. It also has a smaller memory footprint and no unnecessary process wakeups, improving power efficiency.