ThinkPad:ArchLinux: Difference between revisions

From Wiki³
Line 24: Line 24:
It is also a good idea to install PowerTOP in order to monitor power usage.
It is also a good idea to install PowerTOP in order to monitor power usage.
{{Console|1=yaort -S powertop}}
{{Console|1=yaort -S powertop}}
=== CPU ===
First begin by installing {{mono|cpupower}} and {{mono|upower}}.
{{Console|1=yaourt -S cpupower upower}}
Create udev rules for automatically changing the governor when the system is running.
{{Console|1=sudo vim /etc/udev/rules.d/powersave.rules}}<br/>
{{Console|prompt=false|1=SUBSYSTEM{{=}}{{=}}"power_supply", ATTR{online}{{=}}{{=}}"1", RUN+{{=}}"/usr/bin/laptopmode AC"<br/>SUBSYSTEM{{=}}{{=}}"power_supply", ATTR{online}{{=}}{{=}}"0", RUN+{{=}}"/usr/bin/laptopmode BAT"}}
Create a systemd service for adjusting the governor when returning from suspend.
{{Console|1=sudo vim /etc/systemd/system/root-resume.service}}<br/>
{{Console|prompt=false|[Unit]<br/>Description{{=}}Local system resume actions<br/>After{{=}}suspend.target<br/><br/>[Service]<br/>Type{{=}}simple<br/>ExecStart{{=}}/usr/bin/laptopmode<br/><br/>[Install]<br/>WantedBy{{=}}suspend.target}}
Also create a systemd service for adjusting the governor on system boot-up.
{{Console|1=sudo vim /etc/systemd/system/power_management.service}}<br/>
{{Console|prompt=false|[Unit]<br/>Description{{=}}Sets the CPU governor on boot according to AC mode<br/>Requires{{=}}multi-user.target<br/>After{{=}}multi-user.target<br/><br/>[Service]<br/>Type{{=}}oneshot<br/>RemainAfterExit{{=}}no<br/>ExecStart{{=}}/usr/bin/laptopmode<br/><br/>[Install]<br/>WantedBy{{=}}multi-user.target}}
Finally create the script itself to switch modes.
{{Console|1=sudo vim /usr/bin/laptopmode}}<br/>
{{Console|prompt=true|#!/usr/bin/bash<br/><br/>STATE{{=}}""<br/>BAT{{=}}"BAT1"<br/><br/>if &#91;&#91; "$1" {{=}}{{=}} "BAT" {{!}}{{!}} "$1" {{=}}{{=}} "AC" &#93;&#93;; then<br/>        STATE{{=}}"$1"<br/>fi<br/><br/>if &#91;&#91; $STATE {{=}}{{=}} "" &#93;&#93;; then<br/>        if &#91;&#91; $(upower -i /org/freedesktop/UPower/devices/battery_$BAT {{!}} grep state {{!}} grep discharging) {{=}}{{=}} "" &#93;&#93;; then<br/>                STATE{{=}}"AC"<br/>        else STATE{{=}}"BAT"<br/>        fi<br/>fi<br/><br/>echo $STATE<br/><br/>if &#91;&#91; $STATE {{=}}{{=}} "BAT" &#93;&#93;; then<br/>        echo "Discharging, set governor to powersave and disabled Turbo Boost"<br/>        cpupower frequency-set -g performance<br/>        cpupower frequency-set -f 2500MHz<br/>        echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo<br/>elif &#91;&#91; $STATE {{=}}{{=}} "AC" &#93;&#93;; then<br/>        echo "AC plugged in, set governor to performance and enabled Turbo Boost"<br/>        cpupower frequency-set -g performance<br/>        cpupower frequency-set -f 3500Mhz<br/>        echo 0 > /sys/devices/system/cpu/intel_pstate/no_turbo<br/>fi}}


=== Fan Control ===
=== Fan Control ===
Line 59: Line 43:
{{Console|1=sudo systemctl enable thinkfan|2=sudo systemctl start thinkfan}}
{{Console|1=sudo systemctl enable thinkfan|2=sudo systemctl start thinkfan}}


=== HDD/SSD ===
=== SSD ===
First if you want to enable TRIM on boot, create a systemd service.
Also create a systemd service for adjusting the governor on system boot-up.
{{Console|1=sudo vim /etc/systemd/system/ssd-trim.service}}<br/>
{{Console|prompt=false|[Unit]<br/>Description{{=}}Runs fstrim on the SSD<br/>Requires{{=}}multi-user.target<br/>After{{=}}multi-user.target<br/><br/>[Service]<br/>Type{{=}}oneshot<br/>RemainAfterExit{{=}}no<br/>ExecStart{{=}}/usr/bin/fstrim -v /<br/><br/>[Install]<br/>WantedBy{{=}}multi-user.target}}
To monitor the HDD or SSD installed you need to install the {{mono|smartmontools}} package.
To monitor the HDD or SSD installed you need to install the {{mono|smartmontools}} package.
{{Console|1=yaourt -S smartmontools}}
{{Console|1=yaourt -S smartmontools}}

Revision as of 23:42, 15 July 2017

IconUNDER CONSTRUCTION: The document is currently being modified!

Customization

Keeping the Boot Log on TTY1

In order to stop Arch Linux from clearing the screen on boot we can add the i915 module to MODULES inside of /etc/mkinitcpio.conf and then regenerate our kernel images.

# sudo sed -i -r 's/^MODULES="([a-z0-9 _-]+)"/MODULES="\1 i915"/' /etc/mkinitcpio.conf
# sudo mkinitcpio -p linux

Then create a directory for getty overrides and create one with the following.

# sudo mkdir /etc/systemd/system/getty@tty1.service.d
# sudo vim /etc/systemd/system/getty@tty1.service.d/noclear.conf


[Service]
TTYVTDisallocate=no

Traditional Device Node Names

To translate the predictable device node names back into traditional ones, can create the following. You can use the vim command :r !cat /sys/class/net/wlp3s0/address, replacing the device node respectively, in order to get the MAC Address of each device.

# vim /etc/udev/rules.d/10-network.rules


SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="MAC_ADDRESS_FOR_NIC", NAME=="eth0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="MAC_ADDRESS_FOR_WIFI", NAME=="wlan0"

Hardware

Battery/CPU

Install TLP and related packages. Then enable it with systemd, don't forget to mask the required services (skip NetworkManager if you use this).

# yaourt -S tlp tp_smapi acpi_call
# sudo systemctl enable tlp
# sudo systemctl enable tlp-sleep


# sudo systemctl mask NetworkManager.service
# sudo systemctl mask systemd-rfkill.service
# sudo systemctl mask systemd-rfkill.socket

TLP status can be shown with the following:

# sudo tlp-stat

It is also a good idea to install PowerTOP in order to monitor power usage.

# yaort -S powertop

Fan Control

Install thinkfan, default configuration is installed into /usr/lib/modprobe.d/thinkpad_acpi.conf.

# yaourt -S acpi lm_sensors thinkfan

Then detect the hardware monitors chips that are available. Then re-enable the thinkpad_acpi kernel module to update with the new config.

# sudo sensors-detect
# sudo modprobe thinkpad_acpi

To show the current thermal and cooling information use acpi.

# sudo acpi -V

To show the current fan speed and level.

# sudo cat /proc/acpi/ibm/fan

Make the changes to point it to the right temperature reading, you can use :r !sudo find /sys/devices -type f -name "temp*_input" in order to paste all the monitors into the file.

# sudo vim /etc/thinkfan.conf

When finished it should look something like this:

hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp2_input
hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp3_input
hwmon /sys/devices/virtual/hwmon/hwmon1/temp1_input
tp_fan /proc/acpi/ibm/fan

(0, 0, 35)
(1, 33, 38)
(2, 36, 45)
(3, 39, 49)
(4, 46, 58)
(5, 50, 62)
(7, 56, 32767)

You can verify the config is written correctly with the following command.

# sudo thinkfan -n

Finally enable and start thinkfan.

# sudo systemctl enable thinkfan
# sudo systemctl start thinkfan

SSD

First if you want to enable TRIM on boot, create a systemd service. Also create a systemd service for adjusting the governor on system boot-up.

# sudo vim /etc/systemd/system/ssd-trim.service


[Unit]
Description=Runs fstrim on the SSD
Requires=multi-user.target
After=multi-user.target

[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/usr/bin/fstrim -v /

[Install]
WantedBy=multi-user.target

To monitor the HDD or SSD installed you need to install the smartmontools package.

# yaourt -S smartmontools

You can view an overall health assessment with the following:

# sudo smartctl -H /dev/sdX