Linux Mint 18 on Lenovo T420s
I recently installed Linux Mint 18 on my old trusty Lenovo Thinkpad T420s. This post is about the tweaks and tools I used to make the machine run great. Read on for tweaks specific to Thinkpads, general tweaks for laptops and tips relevant for dual booting Windows and Linux.
Thinkpad T420s showing a picture of its younger self:
32 or 64-bit?
I wrote a similar post a couple of years ago about installing Linux Mint 15 on the same machine. Back then I decided to go for the 32-bit Mate edition.
This time I opted for 64-bit as the balance seems to have tilted to favor 64-bit releases as the most popular and best supported. There is no good reason to choose 32-bit anymore for me. It also helps that the machine has been upgraded to 8 GB RAM, but even with 4 GBs of RAM I would have chosen a 64-bit Linux distribution.
Mate vs. other window managers?
Mate keeps working great for me, so I didn't really consider changing to another window manager.
Also, the start menu seems to be working better than it did in Mint 15. My favorite way of starting programs now works, which is to simply hit the Win key, type the first few letters of the program and then hit enter.
Installation
I downloaded the MATE 64-bit .iso file from here and made a bootable USB drive out of it.
Since the machine must dual boot Windows and Linux, I chose the advanced disk partitioning option and instructed the installer to reformat and reuse my old Linux partition. Please only do this if you know what you are doing!
The installation went problem free.
Thinkpad specific tweaks
Here are a few tweaks relevant to the T420s and perhaps other Thinkpads.
Increasing trackpoint speed
The trackpoint is by default too slow for my liking. Here's how to make it faster.
1. Experiment with the speed / sensitivity values with:
$ echo -n 80 > /sys/devices/platform/i8042/serio1/serio2/speed
$ echo -n 250 > /sys/devices/platform/i8042/serio1/serio2/sensitivity
2. To make the favorite settings permanent, create a /etc/udev/rules.d/trackpoint.rules
file containing:
KERNEL=="serio2", SUBSYSTEM=="serio", DRIVERS=="psmouse", ATTR{sensitivity}:="250", ATTR{speed}:="80"
3. Reboot or use the following to load the new settings:
$ sudo udevadm control --reload-rules
$ sudo udevadm trigger
Thinkfan
The hardware control of the fan in my T420s works really bad, so I have to use a custom solution in both Windows and Linux. For Linux, I use thinkfan. The installation process was somewhat different than in my Mate 15 guide. A lot of useful information was found here.
First, install required packages:
$ sudo apt install lm-sensors thinkfan
Adapt the thinkfan configuration file for the machine. The following is the configuration file I use for my T420s. Contents of /etc/thinkfan.conf
:
######################################################################
## thinkfan 0.9 example config file
## ================================
##
hwmon /sys/class/hwmon/hwmon0/temp1_input
tp_fan /proc/acpi/ibm/fan
(0, 0, 40)
(1, 35, 45)
(2, 40, 51)
(3, 42, 53)
(4, 46, 60)
(5, 53, 66)
(7, 60, 72)
(127, 70, 32767)
Note that the final fan speed level is 127. This is necessary to make the fan go to full speed on my machine for some reason.
Enable fan control in the thinkfan_acpi kernel module by making a file: /etc/modprobe.d/thinkpad.conf
with the contents:
options thinkpad_acpi fan_control=1
After a reboot, test if thinkfan will start properly with:
$ sudo thinkfan -b 0 -s 5 -n
sleeptime=5, tmax=50, last_tmax=50, biased_tmax=50 -> fan="level 4"
sleeptime=2, tmax=62, last_tmax=59, biased_tmax=62 -> fan="level 5"
sleeptime=2, tmax=66, last_tmax=64, biased_tmax=66 -> fan="level 7"
sleeptime=5, tmax=60, last_tmax=63, biased_tmax=60 -> fan="level 5"
sleeptime=2, tmax=67, last_tmax=65, biased_tmax=67 -> fan="level 7"
sleeptime=5, tmax=59, last_tmax=62, biased_tmax=59 -> fan="level 5"
sleeptime=3, tmax=66, last_tmax=65, biased_tmax=66 -> fan="level 7"
sleeptime=5, tmax=60, last_tmax=64, biased_tmax=60 -> fan="level 5"
Looks fine, press Ctrl+c to stop it again.
Now lets try if the systemd service works:
$ systemctl start thinkfan.service
Check that fancontrol is running: (level must be different from auto)
$ cat /proc/acpi/ibm/fan
status: enabled
speed: 3893
level: 3
commands: level <level> (<level> is 0-7, auto, disengaged, full-speed)
commands: enable, disable
commands: watchdog <timeout> (<timeout> is 0 (off), 1-120 (seconds))
All good, we can enable thinkfan to start at boot using the systemd service:
$ sudo systemctl enable thinkfan.service
Non Thinkpad specific installation tips
Improving battery life
Linux Mint 18 now uses systemd for managing the OS state which means the AC / battery power optimizing script from the Mint 15 guide can't easily be used anymore. It seems there is no easy way to have a script run when the machine changes power supply mode anymore.
So, I went looking for alternatives and found an even better method than using a home made potentially buggy script. Simply install tlp:
$ sudo apt install tlp
This tool seems to do all the important power optimization tweaks by its default configuration. I didn't need to modify anything. Easy!
The tool also supports a lot of advanced operations with regard to the battery and has a number of Thinkpad specific commands as well. I didn't try any of those functions.
SSD tweaks
It shouldn't be necessary with modern kernels to make system tweaks to accommodate SSD drives, so I didn't do any. I'm using a Samsung 840 EVO 250 GB, and it works just fine like that.
Making Windows use UTC for the real time clock
Linux expects the PC real time clock to be set to UTC time and Windows expects it to be local time. If living in any other time zone than UTC+0 this will cause the clock to shift back and forth when switching OS.
I fixed the problem by configuring Windows to use UTC. Make a set-rtc-to-utc.reg
file with the contents:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001
and double-click it.
Grub to default the last selected OS
The Grub2 bootloader is installed by Linux and used for selecting the OS to boot in case of dual booting. I prefer that the bootloader remembers the choice of OS and uses it for the default at next boot. To make Grub2 do that, edit /etc/default/grub
and make the following settings active:
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
Then run:
$ sudo update-grub
For more info see this post.
Compiling keepassx version 0.4.4
I'm still using an old version of keepassx that uses the version 1 password database. In Linux Mint 18 the version shipped in the repository is a version 2, and I didn't feel like upgrading.
Compiling keepassx version 0.4.4 didn't work out of the box, however, here's what I had to do:
Install qt4 dev:
$ sudo apt install libqt4-dev
From here I found a link to the source tar ball. Download it, pack it out, cd into the folder and build:
$ wget https://www.keepassx.org/releases/0.4.4/keepassx-0.4.4.tar.gz
$ tar -xvf keepassx-0.4.4.tar.gz
$ cd keepassx-0.4.4
$ qmake
$ make
Now, as I did this, the build failed with an error:
lib/random.cpp: In function ‘void initStdRand()’:
lib/random.cpp:98:19: error: ‘getpid’ was not declared in this scope
stream << getpid();
I fixed it by adding an include statement in: src/lib/random.cpp
. Open the file with an editor and add the following line right below #include "random.h"
:
#include <unistd.h>
Make again, and it should succeed.
Then make install to install the program.
$ make install
I hope you enjoyed this content!
Comments powered by Talkyard