Fedora on a ThinkPad P1

ThinkPad P1

Note, this post is based on Fedora 29.  For a more recent experience, see Fedora 30 on a ThinkPad P1. Following on from the successful RHEL8 on a ThinkPad P1 installation I thought I would revisit my Fedora install.

Specifications

As a reminder, here are the specifications of the ThinkPad P1:

  • ThinkPad P1 model 20MDCTO1WW
  • Intel(R) Xeon(R) E-2176M CPU @ 2.70GHz
  • 1 x 32 GB SODIMM, DDR4, Speed: 2667 MT/s, Manufacturer: Samsung, Part Number: M471A4G43MB1-CTD
  • 1 TB NVME drive SAMSUNG MZVLB1T0HALR-000L7
  • Graphics NVIDIA Corporation GP107GLM [Quadro P2000 Mobile]
  • 4K UHD Display
  • BIOS version N2EET31W (1.13 )
  • Battery Design Capacity: 80400 mWh

Note: at the time of writing, there were reports that changing between discrete and hybrid graphics or changing the Thunderbolt settings caused issues.  This seems to be dependent on the version of BIOS being used.  Reference: Reddit thread: New BIOS to fix bricks and thermal issues for X1/P1 series from Lenovo. It is recommended to check your BIOS for updates before changing BIOS settings. Additional references:

Installation settings

The Fedora 29 installation wasn’t quite as smooth as the RHEL 8 install. Here are some notes from the various BIOS and boot combinations I used with the Fedora 29 Live USB.

The following combination did not seem to work:

  • Secure Boot disabled, Hybrid Graphics, default boot flags (with or without the ‘quiet’ option in grub)
    Hangs at “Started GNOME Display Manager”
  • Secure Boot disabled, Discrete Graphics, acpi=off boot flag (and remove ‘quiet’ option in grub)
    Gets past “Starting GNOME Display Manager” but left with a flashing cursor on the top left hand corner of the screen.

However, two combinations did work:

Working combination 1:

  • Secure Boot disabled, Hybrid Graphics, acpi=off boot flags (and remove ‘quiet’ option in grub)
    Boots OK, but only 1 CPU is visible! Power functionality restricted – unable to see battery status, manual power off required
  • Hybrid graphics means when booting into Windows we can use the intel graphics for non-intensive work – we can keep the same BIOS setting for both environments
  • Graphics are seen as:
    [user@p1 ~]$ lspci | grep -e VGA
    00:02.0 VGA compatible controller: Intel Corporation Device 3e94
    01:00.0 VGA compatible controller: NVIDIA Corporation GP107GLM [Quadro P2000 Mobile] (rev a1)

Working combination 2:

  • Secure Boot disabled, Discrete Graphics, default boot flags (optionally, remove the ‘quiet’ option)
    Boots OK, all 12 CPUs visible. However, cursor becomes erratic to respond after several minutes of uptime.  The behaviour is similar to the one described in comment 20 of Bugzilla 1573080 kernel-4.16 doesn’t boot on Lenovo P50 although I admit I did not check ‘top’ to confirm CPU usage.

Neither of these options are ideal.  For my latest installation, I thought I would try option 1 and then apply the latest kernel update.  At that point we can then see whether we can remove the acpi=off flag, switch to Discrete Graphics or try the NVIDIA drivers.

Kernel updates

The Fedora 29 kernel shipped with 4.18.16-300 but a ‘dnf update’ at the time of writing brought this to 4.19.4-300.

dnf update kernel

Additional testing without the NVIDIA drivers

I tested the following after fully updating the system:

  • boot the installed operating system and remove the ‘quiet rhgb acpi=off’ boot options.

This booted to the login screen, accepted my credentials but then gave me a blank screen.

Install the NVIDIA drivers

I wanted to keep BIOS settings to ‘hybrid graphics’ so that the integrated GPU can be used when I boot back into Windows, so I decided to reboot (with the ‘quiet rhgb acpi=off‘ flags) and install the NVIDIA drivers in Fedora.

Launching ‘Software’ in Gnome for the first time should prompt you to confirm whether you want to enable Fedora Third Party Software Repositories.  In the event that this doesn’t appear you can install the following RPM which adds some repositories in /etc/yum.repos.d.

sudo dnf install fedora-workstation-repositories-29-1.fc29.noarch

Search for ‘nvidia’ in the software window and the ‘NVIDIA Linux Graphics Driver’ should be listed.

Fedora NVIDIA Software Packages

Select the NVIDIA Linux Graphics Driver.  The following will appear giving some details about the package and the source – RPM Fusion:

Fedora NVIDIA Linux Graphics Driver Install
Fedora NVIDIA Linux Graphics Driver Install

The installer does the following:

  • Add rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 to the kernel boot options
  • Compiles the NVIDIA kernel modules and installs them into
    /usr/lib/modules/4.19.5-300.fc29.x86_64/extra
    /usr/lib/modules/4.19.5-300.fc29.x86_64/extra/nvidia
    /usr/lib/modules/4.19.5-300.fc29.x86_64/extra/nvidia/nvidia-drm.ko
    /usr/lib/modules/4.19.5-300.fc29.x86_64/extra/nvidia/nvidia-modeset.ko
    /usr/lib/modules/4.19.5-300.fc29.x86_64/extra/nvidia/nvidia-uvm.ko
    /usr/lib/modules/4.19.5-300.fc29.x86_64/extra/nvidia/nvidia.ko

I proceeded to reboot the laptop – first with the ‘acpi=off rhgb quiet‘ options and then without them.  Both options allowed me to boot into the graphical desktop and removing the acpi=off flag allows all the CPUs to become visible and the power management functionality works correctly – battery levels, brightness levels with the function keys, etc.

Remove the acpi=off flag

To remove the ‘acpi=off rhgb quiet’ entries from the EFI menu permanently the following is performed:

Edit /etc/default/grub and identify the GRUB_CMDLINE_LINUX stanza which should read something like this:

GRUB_CMDLINE_LINUX="rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1 resume=UUID=a8b47a6f-1223-42aa-8b73-5c922cee1901 acpi=off rhgb quiet"

Remove the unwanted entries acpi=off rhgb quiet

Regenerate the UEFI menu
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

Verify /boot/efi/EFI/fedora/grub.cfg is as expected and optionally reboot.  Note that I chose to remove the rhgb and quiet options from the boot loader.  This generates extra message on the console but these can sometimes be useful.

Kernel Updates with NVIDIA

The kernel modules with the NVIDIA driver must be rebuilt with each kernel update.  Using the NVIDIA packages from the RPM Fusion repository we installed from the Gnome Software Application takes care of this for us.

I was initially running kernel 4.19.5-300.fc29.x86_64 but 4.19.6-300.fc29.x86_64 was available.  Perform the update as normal:

sudo dnf update

After the update completes, the Akmods daemon builds the NVIDIA package for the new kernel.  In this case, it places it in the following directory:
# ls -l /usr/lib/modules/4.19.6-300.fc29.x86_64/extra/nvidia
total 24792
-rw-r--r--. 1 root root 95664 Dec 7 11:16 nvidia-drm.ko
-rw-r--r--. 1 root root 22108608 Dec 7 11:16 nvidia.ko
-rw-r--r--. 1 root root 1353760 Dec 7 11:16 nvidia-modeset.ko
-rw-r--r--. 1 root root 1818664 Dec 7 11:16 nvidia-uvm.ko

Important: after the dnf command completes it will take a short time (less than a minute) to compile the module. Do not reboot until this process completes.

Power Management

TLP – Linux Advanced Power Management can enhance the battery life on the ThinkPad P1.  The installation is fairly straightforward.  To begin, install tlp and smartmontools from the standard Fedora repos:

dnf install tlp smartmontools

Take a backup of the default TLP configuration:
cp -p /etc/default/tlp /etc/default/tlp.default

Optionally edit /etc/default/tlp and alter the battery charge thresholds:
START_CHARGE_THRESH_BAT0=40
STOP_CHARGE_THRESH_BAT0=45

The above is a good option if the ThinkPad is mainly used at a desk with a plugged in power supply.  This should extend the life of the battery.  The drawback is that if you need to charge the battery to 100% so you can work without the power supply, you’ll have to stop the TLP service or alter the settings.

Install the ThinkPad specific kernel modules for TLP:
dnf install http://repo.linrunner.de/fedora/tlp/repos/releases/tlp-release.fc$(rpm -E %fedora).noarch.rpm
dnf install akmod-tp_smapi akmod-acpi_call kernel-devel

For further information about these modules, see Which kernel module do i need for my hardware, tp-smapi or acpi-call?  I noted that the ‘akmod-tp_smapi’ module didn’t seem to be required on the ThinkPad P1 – but as per the previous link “remove the unnecessary module package…. However, it doesn’t hurt to keep both.”

Enable the service and start it at boot time:

systemctl enable tlp.service
systemctl start tlp.service

To monitor the TLP service:
tlp-stat

Summary

With a few tweaks, Fedora 29 is running on the ThinkPad P1 using the NVIDIA Graphics driver and with ‘hybrid’ options selected in the BIOS.  TLP settings are working fine.

Useful resources

5 thoughts on “Fedora on a ThinkPad P1

  1. Good post, didn’t know about tlp. I have ThinkPad P1 running Fedora 29 for almost a month. All looks good. At the momembt of writing this battery KDE Widget says it will last for 8:43 (96%), but I guess that is a bit too optimistic.
    I have 3 things which don’t let me be fully satisfied:
    – Connecting / Disconnecting external monitor.
    The only way I managed to connect external monitor was to setup bumblebee and launch “intel-virtual-outputs -b” after connecting external monitor. That turns bumblebee on, which powerup Nvidia card. You need that because HDMI port is wired to Nvidia card. I use external monitor as a main monitor and I have to readjust xrandr settings every time I connect monitor (I use KDE Systems Settings for that). If I disconnect external monitor while desktop is extended when KDE freezes and I have to kquitapp5 plasmashell && kstart5 plasmashell to get it back. The proper way to disconnect is to press Fn+F7, choose screen mirroring and then disconnect monitor. To save battery you need to kill intel-virtual-outputs to turn off Nvidia card. It would be nice to have a automation for that – run the script then monitor is connected and disconnected.
    – Screen tearing on external monitor
    Screen tearing is annoying. Even browser scrolling is affected by that, not speaking about video playback on external montior. Looked all around, but none of the suggested settings helped (VSync in nvidia-settings, environement variables setting in profile).
    – Sometimes fans are too noisy when working on power
    Then working with power cord plugged in Fans go too loud sometimes. I tried to use thinkfan and fancontrol services to adjust temperatures and fan speeds to something not that annoying, but did not come to a anything which let me forget about fans. it is interesting that this laptop has 2 fans, but you can control only one. The other (on the left hand side) can’t be controlled. Working on battery fans are quiet, no complains. I guess that temperatures goes a bit higher with power cable connected because usually I work with external monitor which requires Nvidia card to be on.
    One more thing is strange electrical noise comming from laptop. When you work in really quiet environment you can always hear some kind of noise coming from laptop. It is difficult explain what kind of noise is that, but it is something similar you can hear being under high voltage wires.

  2. Great post! Have you had any suspend/ hibernation issues on the P1 running Fedora 30? The feature doesn’t even seem to be available for me.

Leave a Reply

Your email address will not be published. Required fields are marked *