Running with Ruby

Category: Other (page 1 of 11)

Lenovo ThinkPad X1 Carbon (6th Gen / 2018) Ubuntu 18.04 Tweaks

Warning: 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.

Yesterday I’ve finally received my new Lenovo ThinkPad X1 Carbon 6 gen laptop. I cannot say anything bad about the hardware. It fits exactly into my needs and requirements. Unfortunately, there are some flaws when used with Linux (Ubuntu in my case). Here are some hints on how to make things better.

Touchpad and Trackpoint under Linux

This is the most irritating issue that you will encounter.

Note: There are few of ways to solve this problem. None of them worked for me apart from this one.

If you have a touchpad with NFC you may observe following behaviors:

  • it may not detect movements,
  • won’t work with tap-to-click,
  • will occasionally wake up for a couple of seconds and will stop working again.

Unfortunately for this moment, you will have to disable trackpoint to make it work.

Here are the steps you need to follow.

Note: I’m mentioning also things you should not do just in case you’ve followed other instructions that didn’t work.

  1. Disable trackpoint in the BIOS settings.
  2. Disable NFC in the BIOS settings.
  3. Don’t disable trackpad in the BIOS settings (or enable it if you did) – this will make your touchpad embedded buttons work.
  4. You don’t have to use psmouse.synaptics_intertouch=1 at all for GRUB (no GRUB changes) and if you’ve applied this change, please revert it as followed:
    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
    
  5. Don’t remove i2c_i801 from /etc/modprobe.d/blacklist.conf (it needs to be present and uncommented).
  6. Install the 4.17.0-41770rc5-generic (or newer) Linux kernel from the mainline based on the instructions presented below.
  7. Reboot your system with the new Kernel.
  8. Be happy with your working touchpad with the bottom physical buttons.

Installing the mainline kernel

  1. Go here: http://kernel.ubuntu.com/~kernel-ppa/mainline/
  2. Download all the files for a selected kernel version from the Build for amd64 group except those with the lowlatency in their name. For me that was 4 files overall.
  3. Open a terminal and go to the location where you’ve downloaded the files.
  4. Run following command:
    sudo dpkg -i *.deb
    
  5. Reboot.

low cTDP and trip temperature in Linux

This problem is related to thermal throttling on Linux, that is set much below the Windows values. This will cause your laptop to run much slower than it could under heavy stress.

Before you attempt to apply this solution, please make sure that the problem still exists when you read it. To do so, open a Linux terminal and run following commands:

sudo apt-get install msr-tools
sudo rdmsr -f 29:24 -d 0x1a2

If you see 3 as a result value (or 15 when running on battery), you don’t have to do anything. Otherwise:

  1. Disable Secure Boot in the BIOS (won’t work otherwise)
  2. Run this command:
    sudo apt install git virtualenv build-essential python3-dev \
      libdbus-glib-1-dev libgirepository1.0-dev libcairo2-dev
    
  3. Clone this git repository and enter it:
    git clone https://github.com/erpalma/lenovo-throttling-fix.git
    cd lenovo-throttling-fix/
    
  4. Install the patches:
    sudo ./install.sh
    
  5. Check again, that the result from running the rdmsr command is 3

Too small (or too big) letters for WQHD resolution

If you’ve got yourself Carbon version with the WQHD screen, you may notice that everything is extremely big (or super small). That’s because of the scaling factor. Unfortunately, you cannot use fractional scaling (more details here), which means that you’ll end up either with everything being super small (100%) or super large (200%).

Luckily for you, there’s an easy way out. Install Gnome-Tweak-Tools as followed:

sudo apt-get install gnome-tweak-tool

run it and set the Font Scaling Factor to 1,50.

Summary

I was kinda surprised with the amount of tuning required to make this laptop work with Ubuntu. I always considered Lenovo to be Linux friendly, especially that it is a brand loved by many programmers. On the other hand, maybe that’s exactly the reason why they didn’t put too much effort into making sure everything works out of the box. We’re programmers – we can fix that stuff on our own ;)

Anyhow, enjoy your X1 Carbon as much as I do!

Picture taken from the Lenovo website

Apache Zookeeper + Apache Kafka start / restart script

During my  work on Karafka framework I have to start/stop/restart Apache Kafka and Zookeeper quite often. Here’s a short script that will pull the most recent version of Kafka and Zookeeper, will run them and print their IPs.

Note, that it will also stop Kafka and Zookeeper if they were running.

ZOOKEEPER_CHROOT='/kafka'

docker stop zookeeper
docker stop kafka
docker rm zookeeper
docker rm kafka

docker pull jplock/zookeeper
docker pull ches/kafka

docker run \
  -d \
  -e ZOOKEEPER_CHROOT=$ZOOKEEPER_CHROOT \
  --name zookeeper \
  jplock/zookeeper:3.4.6

docker run \
  -d \
  -e ZOOKEEPER_CHROOT=$ZOOKEEPER_CHROOT \
  --name kafka \
  --link zookeeper:zookeeper \
  ches/kafka

ZOOKEEPER_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' zookeeper)
KAFKA_IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' kafka)

echo "Zookeeper chroot: $ZOOKEEPER_CHROOT"
echo "Zookeeper: $ZOOKEEPER_IP"
echo "Kafka: $KAFKA_IP"
Olderposts

Copyright © 2018 Running with Ruby

Theme by Anders NorenUp ↑