ThinkPad X220: Arch Linux Notes

From Wiki³
Jump to: navigation, search

This is a compilation of information I have scoured off the net in order to get my ThinkPad X220 running in the best possible configuration possible for my needs. If you need assistance installing Arch Linux, refer to the installation tutorial linked above.

IconI personally use aur:pacaur to manage all of the packages on my Arch system as it can interface with the regular repositories and the AUR. However, use whatever you are comfortable with.

Keep in mind all of this is optional and none of it is by any means required and should be used on a case by case basis.

Icon Pre-Install

My personal ThinkPad X220 Arch Linux configuration includes LUKS on LVM. For this I did a security wipe of my SSD before the installation.

Begin by downloading the ThinkPad Drive Erase Utility, this is used for performing a security wipe on an SSD. Given that the ThinkPad X220 BIOS puts all SSDs into the frozen state on boot, which makes it challenging to use hdparm to secure wipe them, this utility is the only safe way to perform a security wipe.

Next use El Torito to convert the ISO downloaded into a bootable image file and dd it to a USB disk (or other form of writable bootable media). If aur:geteltorito is not installed, do so before hand. Also make sure you specify the correct disk node to write the image to, you can use lsblk to find the device node.

# pacaur -S geteltorito
# -o securewipe.img 83fd04ww.iso
# sudo dd if=securewipe.img of=/dev/sdX bs=10M

Reboot the machine booting off the prepared media; follow the steps presented.

IconWARNING: Using the disk erase will prompt you with a code to write down and then enter after a reboot. DO NOT skip this part.

Icon Post-Install

Icon 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.

# sudoedit /etc/mkinitcpio.conf

filename: /etc/mkinitcpio.conf
MODULES="… i915"

# sudo mkinitcpio -p linux

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

# sudo mkdir /etc/systemd/system/[email protected]
# sudoedit /etc/systemd/system/[email protected]/noclear.conf

filename: /etc/systemd/system/[email protected]/noclear.conf

Icon Traditional Device Node Names

To translate the predictable device node names back into traditional ones, 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 pasted into vim.

filename: /etc/udev/rules.d/10-network.rules
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="ETHERNET:MAC:ADDRESS", NAME="wired0"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="WIFI:MAC:ADDRESS", NAME="wifi0"

Icon Console Fonts

Everyone have their own opinion, you can pull up a list with ls /usr/share/kbd/consolefonts. To test out a font use setfont, issue the command by itself to return to the default. You can also issue showconsolefont to show a list of all available characters.

# setfont -m 8859-2 gr928-8x16-thin
# showconsolefont

This can be set at boot by adding it to /etc/vconsole.conf.

filename: /etc/vconsole.conf

Icon Auto-Login

IconIt would be advised to skip this section unless you use full disk encryption

Since I am using full disk encryption and I am prompted for a password before I ever even get to login to the system there is no reason to have two separate logins. Therefore, to setup an auto-login on TTY1 edit the service.

# sudo systemctl edit [email protected]

Paste in the following (changing the username accordingly):

ExecStart=-/usr/bin/agetty --autologin kyau --noclear %I $TERM

Icon Auto-Start Xorg on Graphical Boot

Next to get Xorg to auto-start only when systemd has reached a one can merely use a little bash magic. Add the following to the end of ~/.bashrc.

filename: ~/.bashrc
SYSTEMD_TARGET=`systemctl list-units --type target | g graphical | sed 's/ / /' | cut -d " " -f3`
if [ "$SYSTEMD_TARGET" = "active" ]; then
if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
exec startx

Icon Applications

Personally, I keep a running backup of all of my dotfiles on GitHub along with a script to redo all the symbolic links. This makes the process as simple as:

# git clone && cd dotfiles && ./ && logout

Once Xorg is installed and my shell environment and config files are in place, I usually then run my application install script.

IconGitHub: My current pkgstrap.

Icon Hardware

Icon 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).

# pacaur -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

Then edit the tlp config file to setup your TLP profile.

IconGitHub: My current tlp config. I highly suggest looking at the default as it is fully commented.
# sudoedit /etc/defaults/tlp

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.

# pacaur -S powertop

Icon Fan Control

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

# pacaur -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.

IconGitHub: My current thinkfan.conf
# sudoedit /etc/thinkfan.conf

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

Icon Kernel

Since the target system is a laptop the watchdog timer is not needed. This is typically used on systems that have mission-critical roles (i.e. servers), or because of the lack of power reset (i.e. embedded devices). However, when running a desktop or laptop this feature is not needed. To disable it merely add nowatchdog to your kernel options.

Edit your rEFInd config to modify kernel options.

# sudoedit /boot/EFI/BOOT/refind.conf

At this point your kernel options should looks something similar to the following:

filename: /boot/EFI/BOOT/refind.conf
options "rd.luks.uuid=PARTUUID-sda1-root-LUKS-encryptedXXX \ rd.luks.options=discard root=/dev/mapper/x220-root resume=/dev/mapper/x220-swap \
rw add_efi_memmap initrc=\intel-ucode.img nowatchdog"

Since the watchdog is now disabled the kernel module is no longer required to auto-start, blacklist it by adding a config to /etc/modprobe.d.

# echo "install iTCO_wdt /bin/false" | sudo tee /etc/modprobe.d/thinkpad.conf

Then add that config to the FILES section inside of /etc/mkinicpio.conf.

filename: /etc/mkinitcpio.conf
FILES="… /etc/modprobe.d/thinkpad.conf"

Finally rebuild the initramfs.

# sudo mkinitcpio -p linux

Icon Keyboard & TrackPoint

For ideal usage the Touchpad has been disabled in BIOS, the TrackPoint middle click is then disabled and the menu key between the right alt and ctrl is remapped to Super (ie. Windows Key).

filename: ~/.Xmodmap
pointer = 1 9 3 4 5 6 7 8 2 10
keycode 135 = Super_R
IconRemove the first line with 1 9 3 4.. in order to only remap Menu

You will still be able to use the middle TrackPoint button to hold and scroll but it will no longer annoy you by pasting the clipboard.
Don't forget to load this when Xorg starts by inserting it into either ~/.xinitrc or the window manager's autostart file. Alternately it can be run from the prompt for immediate change.

# xmodmap ~/.Xmodmap

For the TrackPoint we can max out the speed and up the sensitivity a bit, defaults are 97 for speed and 200 for sensitivity. For this create a systemd service to change them on boot.

filename: /etc/systemd/system/trackpoint.path
Description=Lenovo Trackpoint Attributes



filename: /etc/systemd/system/trackpoint.service
Description=Set TrackPoint attributes


Create the script to change the Sysfs rules.

filename: /usr/local/bin/trackpoint

echo 200 > /sys/devices/platform/i8042/serio1/speed
echo 220 > /sys/devices/platform/i8042/serio1/sensitivity

# sudo chmod a+x /usr/local/bin/trackpoint

Then enable and start the service.

# sudo systemctl enable trackpoint.path
# sudo systemctl start trackpoint.path

Icon Removable Storage Encryption

Use an additional disk (USB, SD) in order to bolster the X220 disk space in addition to the two hard drive bays. This will take you through adding one with LUKS and ext4.

Icon SSD

For SSD trimming there are a couple of options.

Weekly TRIM

For most a weekly fstrim should be most effective. This single command can take care of all of that.

# sudo systemctl enable fstrim.timer

Continuous TRIM

For continuous trimming add ,discard to the filesystem mount options for the root partition.

# sudoedit /etc/fstab

LVM Trim

If LVM it being run on the SSD, also enable trim in the lvm.conf

filename: /etc/lvm/lvm.conf
issue_discards = 1

S.M.A.R.T Monitoring

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

# pacaur -S smartmontools

You can view an overall health assessment with the following:

# sudo smartctl -H /dev/sdX

Enable and start the smartd systemd service to enable SMART monitoring for all disks.

# sudo systemctl enable smartd

We can also have SMART email us and run a script for notifications on SMART errors.

# sudo sed -i 's/^DEVICESCAN/DEVICESCAN -m address\ -M exec \/usr\/local\/bin\/smartdnotify/' /etc/smartd.conf

Then create the /usr/local/bin/smartdnotify script (replacing both instances of kyau with your username).

filename: /usr/local/bin/smartdnotify
sudo -u kyau DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/kyau/bus notify-send \
"S.M.A.R.T Error ($SMARTD_FAILTYPE)" "$SMARTD_MESSAGE" --icon=dialog-warning

# sudo chmod +x /usr/local/bin/smartdnotify

Then you can start the service.

# sudo systemctl start smartd

Icon Video

IconMost X220 laptops will not need this option, it has been left here for niche uses.

To fix the Intel HD 3000 graphics showing tearing during video playback or other fast movement on the screen.

filename: /etc/X11/xorg.conf.d/20-intel.conf
Section "Device"
Identifier "Intel HD 3000 Graphics"
Driver "intel"
Option "TearFree" "true"

Icon tmpfs

tmpfs can be used to mount portions of your ram for use as temporary directories. The advantages of this are multi-fold: speed (RAM is much faster than any HDD or SSD), security (the files get wiped on boot, which removed the need for periodic cleanup) and finally, given that this is usually the most written data to the disk it will increase the life of your disk by reducing wear.

Icon Browser Profile

Putting the web browser's user profile directory onto tmpfs can dramatically speed up the browser.

To get started install profile-sync-daemond.

# pacaur -S profile-sync-daemon

Run profile-sync-daemon once to generate the user config.

# psd

Edit the configuration and specify which BROWSERS you are using, I personally only use google-chrome-stable. It is also a good idea to enable overlayfs to decrease the memory footprint and increase sync speed.


When using overlayfs it is also required to give the program sudo rights, we can do this for only this program by using visudo.

# sudo visudo

Add a line that for overlayfs replacing my username with your own.

kyau ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper

With that set we can run profile-sync-daemon one last time manually to preview what it will setup.

# psd p

Provided everything is as it should be, enable and then start the service.

# systemctl --user enable psd
# systemctl --user start psd

Icon Makepkg

Moving the build directory that makepkg uses to build packages into the /tmp folder will effectively move the package building temporary directory into memory.

filename: /etc/makepkg.conf

Icon User Cache

In order to speed up programs that store lots of temporary cached data on the local disk, put the user's cache directory into a tmpfs ramdisk.

Insert a line into the fstab for your user.

filename: /etc/fstab
tmpfs /home/kyau/.cache/ tmpfs defaults,noatime,mode=1777,nosuid,nodev,uid=kyau,gid=users 0 0