← Tiny Subversions

Fix for Thinkpad X1 Carbon Gen 9 overheating in Ubuntu

by Darius Kazemi, Aug 4, 2021

I recently got a Thinkpad X1 Carbon Gen 9 laptop and am running Ubuntu 20.04 LTS on it as the only operating system. Something I noticed was that it hard rebooted under heavy loads, which to me seemed like there was an issue with the CPU overheating.

Confirming the problem by logging CPU temperatures

To debug, I installed this sensor package:

$ sudo apt install lm-sensors

Then I created a little script called sensorlog.sh with the following contents:

date >> /home/MYUSERNAME/sensor-log.txt
sensors | grep C >> /home/MYUSERNAME/sensor-log.txt

I edited /etc/crontab and added the following line to the end of the file:

* * * * *   dariusk /home/dariusk/bin/sensorlog.sh

This runs the script every minute. On each minute the script logs the date and time, and the basic temperature information to sensor-log.txt. I ran a bunch of youtube videos and other programs that were causing the reboots, and got a reboot to happen. I checked sensor-log.txt and sure enough the CPU was running a little hot at reboot time (90C, not dangerously hot but high enough that I didn't like it).

NOTE: Make sure to delete or comment out this line in `/etc/crontab` when you're done! No point in logging your temperature to a giant text file after things are fixed.

Fixing the problem

It took a couple hours of searching the web but I found this forum post. It's about the 7th Gen X1 Carbon but it seemed promising anyway. I looked up the package the forum poster said worked -- basically it turns out that Ubuntu doesn't manage power and CPU throttling very well on its own, and there is a package called TLP that tweaks kernel settings to do all sorts of power and CPU management.

Ultimately I ended up running the following commands:

$ sudo add-apt-repository ppa:linrunner/tlp
$ sudo apt-get update
$ sudo apt-get install tlp tlp-rdw -y
$ sudo apt-get install acpi-call-dkms -y

I did not install tp-smapi-dkms in the last step as was done in the forum post because according to the TLP docs that is only for older ThinkPads. Before that last step you can run sudo tlp-stat -b to get a recommendation for which package to install in the last step. Then I rebooted the computer.

Aside: Because I have UEFI SecureBoot enabled, one of these steps asked me to provide a temporary password for security, which I did. On reboot, I had to choose "Validate/Register MOK Key" (or something similar to that! I didn't take a picture) and then enter that temporary password, then "Reboot".

Results looking good

So far, so good. I stress tested my computer as best as I could, and I saw a brief peak at 85C but then it went right back down to about 65C. The CPU is definitely being throttled (videos began to stutter, keyboard began to experience a delay) but that's way better than a hard reboot. I will probably play around with TLP settings to get a good balance of power/performance, but this solved my main terrible problem which was my laptop rebooting during video calls for work!