Tips for Setting Up Linux on AMD based Thinkpad

Recently, I bought a new laptop, it is a Lenovo Thinkpad Neo14. This is an exclusive model for the Chinese market. I was quite happy with the build quality and the look of it, only thing I dislike is it came pre-installed with Windows 11 which bundled many different kind of useless software.

To me, on the second day of getting the laptop, I start installing Linux on it. More specifically, I installed Arch Linux.

Prior Experience with Arch Linux

I had been a long time Linux user, my earlier days of Linux starts with Ubuntu.I started dual-boot Linux and Windows when I got a laptop for my University.
Depending on who you ask, people might tell you Manjaro is not actually Arch. I don't have any strong opinion on this, but over the years, I did learn quite a lot of stuff through using Manjaro, this eventually lead me to migrate to pure Arch when I got the chance to upgrade my laptop SSD from the one that's pre-installed to a NVME SSD.

I have been using Arch since September 2022, I've been quite happy with everything. So for this new laptop, I've decided to continue using Linux. This article will be mainly about the issues I faced during my migration to the new laptop, and how I resolve those issues.

My hope is that this article would serve as a future reference should I need to this kind of migration again. And it would help some other people who face similar issues and find their way here.

Resolving Migration Issues

My approach was a bit different when it comes to 'migration' -- I directly took the SSD from my old Intel laptop and install it on the new one.

Issue #1: Can not boot

No one would expect Linux to be a plug-and-play OS, me neither, so I wasn't too surprised when my new laptop didn't boot correctly. The next thing I did was to get a thumb drive with Arch Linux ISO and boot into it.

Solution:

  • Boot into Arch Linux install ISO.
  • Connect to internet
    • iwctl station wlan0 get-networks
    • iwctl station wlan0 connect
  • Mount the drive for the actual partition and chroot to the actual installed OS with the following:
    • mount /dev/nvme0n1p1 /mnt
    • mount /dev/nvme0n1p2 /mnt/boot (because I had a separate boot drive)
  • Uninstall Intel microcode, install AMD microcode
  • Rebuild the kernel
    • sudo mkinitcpio -k /boot/vmlinuz-linux -c /etc/mkinitcpio.conf -g /boot/initramfs-linux.img -S autodetect

(At this point, I thought I would have a working OS. Sadly enough, when I reboot, I still wasn't able to get to the login manager screen. I was suspecting it is an issue with the graphic drive, so I had to reboot into the install ISO and set the run level, I realized later, I didn't have to do this)

  • Set the run level to use console (or command line interface, no graphical interface) -- systemctl set-default multi-user.target (Alternatively, you can potentially try to use Ctrl-Alt-F2 to drop into console mode when the machine failed to boot to login manager)

Issue #2: Booted with no graphical interface

The next mission was to fix the graphic driver, so it can boot to the graphical interface.
Solution:

  • pacman -Sy xf86-video-amdgpu xf86-video-ati (these two packages are necessary, they are the drivers for the amd integrated graphics card)
  • pacman -Rns xf86-video-nouveau (Uninstall the Intel driver)
  • sudo Xorg -configure (this is to generate the new Xorg config file. This is necessary because my previous laptop was using Intel integrated graphics, and this new one is using AMD)

Issue #3: Miscellaneous fix

The aforementioned issues are the biggest ones, once I got the laptop setup, almost everything are usable, I don't even need to do any more setup. There are several caveats though. Here's a shortlist of those miscellaneous issues.

  • Fix Polybar and Sxhkd for screen brightness
    The changing of screen brightness (aka backlight) from the polybar did not work out of the box. This is sort of expected, cause the previous configuration was based on an Intel graphics card.

    Fixing Polybar:

    My previous polybar configuration was using the xbacklight module, to get the brightness work on my AMD laptop, I had to switch to use brightness module.
    Here's my config for that part

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    [module/brightness]
    type = internal/backlight
    card = amdgpu_bl0
    use-actual-brightness = true

    format = <label>
    label = %{F#BB5F80} %{F-}  %percentage% %

    bar-width = 10
    bar-indicator = |
    bar-indicator-foreground = #fff
    bar-indicator-font = 2
    bar-fill = ─
    bar-fill-font = 2
    bar-fill-foreground = #9f78e1
    bar-empty = ─
    bar-empty-font = 2
    bar-empty-foreground = ${colors.foreground-alt}

    Fixing Sxhkd:

    In Sxhkd config, I previously had a shortcut to use xbacklight to increase or decrease the screen brightness, this did not work with Linux, I switched to use a different software called brightnessctl, everything work as expected.

    Here's updated configuration for the brightness shortcut

    1
    2
    3
    4
    5
    XF86MonBrightnessUp
    brightnessctl set 10%+

    XF86MonBrightnessDown
    brightnessctl set 10%-
  • Vulkan and OpenCL fix
    Vulkan and OpenCL are quite useful in that they provide hardware acceleration to certain software, to me, I use Darktable quite often, so I setup OpenCL acceleration by running the following:
    yay opencl-amd or yay rocm-opencl-runtime. Seems like the later one is more recent and supports the latest GPU, however, in my case, installing the first one also works.
    You can verify your OpenCL installation by running clinfo
    For Vulkan support, install the vulkan-radeon package from aur like below:
    yay vulkan-radeon

References

  • Arch Linux Wiki on chroot: https://wiki.archlinux.org/title/chroot
  • Arch Linux Wiki on GPGPU: https://wiki.archlinux.org/title/GPGPU
  • Arch Linux Wiki on backlight: https://wiki.archlinux.org/title/backlight