Luca's blog about mostly random stuff

A blog about everyday life, programming, linux, karate and ocarinas

View on GitHub
15 August 2018

Lenovo T480 config on Ubuntu

About a month ago I finally bought a new laptop. My previous one (the Microsoft Surface Pro 3) is certainly a great device, it just comes with too many quirks when used with Linux on it. On top of that the wifi chip was broken, making it somewhat useless on the go.

After reading lots of comparisons I went for the Lenovo T480. The build quality is top notch and Ubuntu 18.04 runs out of the box with no further complications. Unfortunately the device is running rather hot, even when idle. The reasons for this are the dedicated Nvidia MX150 GPU as well as the high CPU usage caused by the BIOS’ Thunderbolt settings. I managed to decrease the CPU load and the high energy consumption by performing the settings listed below.

Disabling MX150 on the T480

Out of the box Ubuntu will install “nouveau” graphics drivers. The proprietary nvidia drivers can also be installed by starting “Software & Updates”. The Nvidia driver allows you to easily change the GPU in use, but it merely changing the selection there was not sufficient in my case.

After some reasearch, there seem to be following methods that will properly turn off the dedicated GPU:

Option 1) Proprietary Nvidia drivers and powertop –auto-tune

References:
https://www.reddit.com/r/thinkpad/comments/8a7qtl/returned_my_t480s_got_a_t480_first_impressions/
https://askubuntu.com/a/490401 (register powertop service)
https://askubuntu.com/a/1061055 (disable nvidia-fallback service)

  1. “Software & Updates” > Drivers > Switch to proprietary nvidia drivers
  2. Reboot (while enrolling Secure Boot key)
  3. sudo prime-select intel (or: “Nvidia X Server Settings” > “PRIME Profiles” > Select “Intel (Power Saving Mode)”)

If this already works, great! Powertop was still showing the MX150 to use power though, so following steps were necessary:

  1. Install powertop and disable nvidia-fallback service
sudo apt install powertop
sudo systemctl disable nvidia-fallback.service
  1. Create file /etc/systemd/system/powertop.service with following contents:
[Unit]
Description=PowerTOP auto tune

[Service]
Type=idle
Environment="TERM=dumb"
ExecStart=/usr/sbin/powertop --auto-tune

[Install]
WantedBy=multi-user.target
  1. Enable the service:
sudo systemctl daemon-reload
sudo systemctl enable powertop.service

This will register a new systemd service, automatically running powertop optimizations on startup.

Option 2) Change Display server and blacklist Nvidia drivers

Reference:
https://askubuntu.com/questions/1031511/cant-disable-nouveau-drivers-in-ubuntu-18-04

Another option that seems to work, is blacklisting the nvidia related kernel modules. This generally works by adding something to /etc/modproble.d/blacklist.conf, but since Ubuntu (in my case) is running on Wayland, the display server must be switched back to X11 first.

You can figure out what display server your session is running on by doing the following:

loginctl
>   SESSION        UID USER             SEAT             TTY             
>        c1        120 gdm              seat0            tty1            
>         2       1000 luca             seat0            tty2            

loginctl show-session c1 -p Type
> Type=wayland

To actually switch back to X11, the following step seem to be simple enough (if you are using gnome)

  1. Uncomment WaylandEnable=false in /etc/gdm3/custom.conf

While this changes the display server, it does not change much about the gpu in use. To disable the MX150:

  1. Add the following lines to /etc/modprobe.d/blacklist.conf
blacklist nouveau
blacklist lbm-nouveau
alias nouveau off
alias lbm-nouveau off
  1. sudo update-initramfs -u
  2. restart

Option 3) Proprietary Nvidia drivers and turn off gpu with a service

(This way worked best for my setup)

References:
https://github.com/stockmind/dell-xps-9560-ubuntu-respin/issues/8#issuecomment-389292575/ https://askubuntu.com/a/1061055 (disable nvidia-fallback service)

(Steps 1 - 3 are the same as in Option 1)

  1. “Software & Updates” > Drivers > Switch to proprietary nvidia drivers
  2. Reboot (while enrolling Secure Boot key)
  3. sudo prime-select intel (or: “Nvidia X Server Settings” > “PRIME Profiles” > Select “Intel (Power Saving Mode)”)
  4. Disable nvidia-fallback service sudo systemctl disable nvidia-fallback.service
  5. Create file /etc/systemd/system/gpuoff.service with following contents:
[Unit]
Description=Power-off gpu

[Service]
Type=oneshot
ExecStart=/bin/bash -c "if [[ `prime-select query` == 'intel' ]]; then echo auto > /sys/bus/pci/devices/0000\:01\:00.0/power/control; fi"

[Install]
WantedBy=default.target
  1. Enable the service:
sudo systemctl daemon-reload
sudo systemctl enable gpuoff.service

This will register a new systemd service and depending on whether or not prime-select query return intel turns off the nvidia gpu.

Thunderbolt BIOS Assist Mode (High CPU usage fix)

https://forums.lenovo.com/t5/ThinkPad-T400-T500-and-newer-T/T480-CPU-temperature-and-fan-speed-under-linux/m-p/4114832

BIOS: Config > “Thunderbolt(TM) 3” >

Other power-saving options and configs

I won’t go into too much detail here, but for my own reference, here are the other settings I’ve done.

sudo apt install tlp

BIOS:
Security > “I/O Port Access” >

Software

Editors

Gnome configuration

Misc

git

Input methods

OR

tags: