Ubuntu 18.04 + Lenovo X1 Carbon (6G)

Disclaimer: I’m not responsible for any damages or injury, including but not limited to special or consequential damages, that result from your use of this instructions.

Everything in General Just Worked Out-of-the-Box

In my previous open letter to Apple, I mentioned that the Lenovo Thinkpad X1 Carbon running Ubuntu was a wonderful candidate for a Macbook replacement. So while I am waiting for the late summer hardware event, I decided to do some hands on exploration to prove my theory with some solid day-to-day usage testing on a 6th gen X1 Carbon myself.

The installation went off without a hitch and everything except for the fingerprint reader just worked right out of the box. To my surprise, even the touch screen worked. The only thing that I didn’t check was the SD/Sim slot which I read somewhere that it also doesn’t work out-of-the-box. No big deal for me though as I don’t like using fingerprint readers and have no need for sim/nano SD support. I then connected the HDMI port to my external display and that worked wonderfully as well.

Battery Life

Battery life was left little to be desired out-of-box as expected but nothing that can’t be tuned to an acceptable level of performance by doing the following:

  1. Disable “Secure Boot” in BIOS
  2. Run the below command in the terminal:
sudo apt-get install tlp tlp-rdw acpi-call-dkms tp-smapi-dkms acpi-call-dkms

Without any further tweaks, I already feel a boost in battery life. It works out to about 10 hours of battery life based on my usage patterns. However, for those of you who are “worried papas” or care for very specific battery use parameters for your devices, you can take a look at the “Battery charging threshold” section of this article which goes further into tweaking what’s under the hood. FWIW, I didn’t have any of the touchpad, trackpoint, t̶e̶m̶p̶e̶r̶a̶t̶u̶r̶e̶,̶ ̶o̶r̶ ̶C̶P̶U̶ ̶i̶s̶s̶u̶e̶s̶ it mentions so I didn’t bother with any of the tweaks the author suggested on that end.

Edit (July 4th, 2018):

I did however find that the low latency kernel seems to perform better so I switched to it and the deep sleep still works.

sudo apt install linux-image-4.15.0-24-lowlatency linux-headers-4.15.0-24-lowlatency

Edit (July 22, 2018):

I saw some dropped frames, slowness, keyboard lag, etc especially when on battery that could be due to the graphics driver, CPU management, microcode, and TLP settings. While it’s still usable without these tweaks, I prefer to get the best out of a laptop that I paid a pretty good price for. Here's what I did to make things better.

Disable Wayland from GDM3 just in case Wayland weirdness is affecting graphics performance cause I found that GDM3 was being launched with Wayland. I accomplished this by editing /etc/gdm3/custom.conf:

# Uncoment the line below to force the login screen to use Xorg

Install Open Graphics Drivers PPA:

sudo add-apt-repository ppa:oibaf/graphics-drivers

It proved to not help much and I read that the xserver-xorg-video-intel driver is now deprecated so I removed it so that the graphics card will fall back to the kernel:

sudo apt purge xserver-xorg-video-intel

Install Intel microcode:

sudo apt install intel-microcode

Installed dependencies and cloned the Lenovo Throttling Script:

sudo apt install git virtualenv build-essential python3-dev libdbus-glib-1-dev libgirepository1.0-dev libcairo2-dev
cd ~/Downloads
git clone https://github.com/erpalma/lenovo-throttling-fix.git

Changed the defaults of /etc/lenovo_fix.conf to:

# Update the registers every this many seconds
Update_Rate_s: 5
# Max allowed temperature before throttling
Trip_Temp_C: 80
# Max allowed temperature before throttling
Trip_Temp_C: 90
# CPU core voltage offset (mV)
CORE: -100
# Integrated GPU voltage offset (mV)
GPU: -70
# CPU cache voltage offset (mV)
CACHE: -100
# System Agent voltage offset (mV)

Edit (August 6th)

After tweaking the TLP config on August 4th (scroll down to see), I also increased the undervolting which seems to save a lot of battery life without any compromise in performance. Though I have not tried doing anything super heavy yet. In any case, the battery lasts about more like 6 hours rather than 5 now.

# CPU core voltage offset (mV)
CORE: -110
# Integrated GPU voltage offset (mV)
GPU: -90
# CPU csache voltage offset (mV)
CACHE: -110
# System Agent voltage offset (mV)
# Analog I/O voltage offset (mV)

Applied the fix with my changes:

cd ~/Downloads/lenovo-throttling-fix
sudo -H ./install.sh

Configured TLP with the following settings:

Note: Most of the time, I care more about power over battery life. 6–8 hours of battery life is a lot better than a not responsive enough system to attain 10+ hours of battery life. With that said, these settings are tuned to at least get me 6 hours minimum of battery life which is good enough for my purpose as I have a power source at most of the places I go.

# Dirty page values (timeouts in secs).
# Set energy performance hints (HWP) for Intel P-state governor:
# performance, balance_performance, default, balance_power, power
# Values are given in order of increasing power saving.
# Note: Intel Skylake or newer CPU and Kernel >= 4.10 required.
# Set CPU performance versus energy savings policy:
# performance, balance-performance, default, balance-power, power.
# Values are given in order of increasing power saving.
# Requires kernel module msr and x86_energy_perf_policy from linux-tools.
# Disk advanced power management level: 1..254, 255 (max saving, min, off).
# Levels 1..127 may spin down the disk; 255 allowable on most drives.
# Separate values for multiple disks with spaces. Use the special value 'keep'
# to keep the hardware default for the particular disk.
# AHCI link power management (ALPM) for disk devices:
# min_power, med_power_with_dipm(*), medium_power, max_performance.
# (*) Kernel >= 4.15 required, then recommended.
# Multiple values separated with spaces are tried sequentially until success.
SATA_LINKPWR_ON_AC="med_power_with_dipm max_performance"
SATA_LINKPWR_ON_BAT="med_power_with_dipm medium_power"
# Radio devices to disable on startup: bluetooth, wifi, wwan.
# Separate multiple devices with spaces.

Edit (August 4th)

Did some further TLP tweaking that increased the performance while on battery without loosing too much battery life:

TLP Config

Last but not least, I installed CPU Power Manager Gnome Shell Extension from the Ubuntu Software Store and configured the following profiles so I can have more control of my perf settings based on the situation I am in:

After a swift reboot from all of the changes above, my X1C6 is now more or less hitting the right marks for me. I also watched a few Donnie Yen fight scenes while on battery just to make sure the video output performance is up to par… ;)

Edit (July 27th, 2018):

Something that I did before and mysteriously went away reminded me of how much graphics performance I got out of this fix:

sudo vim /etc/environment

Add the following line and reboot:


Edit (July 29th, 2018):

Firmware Security (v0.1.27) popped up in the Ubuntu Software Store. I was a bit scared as I have read in forums that some updates that are installed from the Lenovo site has rendered the laptop unusable but my personality doesn’t allow outstanding updates to be not installed especially when it’s security related and that I am hopeful that since it’s an Ubuntu pushed update that it was tested and work well. So I went ahead and hit the update button and then rebooted the system. So-far everything works fine on the laptop. Kudos to Canonical for making this so seamless/automated!

S3 — Deep Sleep

I am not much of an electrical engineer so instead of doing in-depth power consumption testing myself, I did some simple tests against all the chatter in the forums about how in the 6th Gen X1 Carbon, Lenovo decided to get rid of the ACPI S3 Deep Sleep state in favor of a “Microsoft driven sleep state called Windows Modern Standby aka Si3” which breaks Ubuntu’s ability to go into the deep sleep state; something quite valuable for road warriors that can’t afford to shutdown or hibernate before they are on the move and yet, demand long battery life in their devices so that they last through their work days.

Before I applied the hacked fix, the laptop goes into the S2 sleep state aka standby right out of the box. This costed me about 1% of battery life every 30–45 minutes. The waking of the laptop was also a bit laggy.

After I applied the hacked fix which I will write a followup post on, I lost around 2% of battery from a 6-7 hour S3 deep sleep. What’s surprising is that the waking of the laptop was also much more snappy than the S2 sleep state.

So problem there also solved. It’s not as great at my Macbook Air per se but I certainly think it’s acceptable.

Edit (July 22nd)

As promised, here’s the step-by-step.

What about Software?

As I have mentioned before, Ubuntu and GNU/Linux in general has come a long ways so I have obviously been able to fill all my requirements with the software through a combination of open and closed source software to pretty much make this setup take care of all my practical needs. Though I must say that my usage behavior doesn’t speak for everyone. I am sure my constant using of Ubuntu on my desktops at work and home for as long as I remember influences my software choice and usage patterns. Here’s a screenshot of my setup:

Happily Ever After?

That pretty much sums up all that I had to do to be generally satisfied with this laptop for my needs. I’ll certainly report back if I run into any new findings as I continue with my exploration.