Recently, I purchased a ThinkPad P14s Gen 5 with an Nvidia dGPU (I know; big mistake. Please don’t do as I did and get yourself the one with AMD instead). This guide documents the installation process of Arch Linux on this laptop.

Before You Start

  1. While most of the steps are taken from Arch Installation Guide, some have been modified to fit and work correctly with the Thinkpad P14s Gen 5. That is to say that this guide is targeting only the Thinkpad P14s Gen 5, for a general installation guide, please refer to the Arch Installation Guide.

  2. Dual-boot(ing) Windows is not covered. For more, please refer to Dual boot with Windows.

  3. Enabling Secure-Boot for grub is not covered. For more, please refer to Unified Extensible Firmware Interface/Secure Boot.

  4. Nvidia driver setup is not covered. This in itself needs a separate article (thanks Nvidia).

  5. The Linux kernel we are going to install is linux-lts. This is because, at the time of writing, the latest Linux kernel has some issues with suspending the system (namely, the system always wakes up immediately after a suspend).

Preparation

Obtain an Arch ISO and flash it onto a USB drive.


Booting into Arch boot image

  1. Restart your system, then when you see Thinkpad splash screen press <Enter>, this should show you a menu with a couple of options. Press <F1> to enter the BIOS setup utility.
  2. Go to Security -> Secure Boot, then disable Secure Boot.
  3. Press Save & Exit. This will restart the system. Then, when you see Thinkpad splash screen press <Enter>, then press <F12> to choose a temporary boot drive.
  4. When the boot menu appears, choose the usb drive that has Arch on it.

Now you are inside the boot image of Arch.

Installation

1. Connect to the Internet

For ethernet, just connect an ethernet cable and you’re all set. For WiFi, use iwctl as follows:

  1. Enter iwctl shell

    iwctl
    
  2. List wifi devices

    [iwd]# device list
    
  3. Scan for networks and list them

    [iwd]# station <device-name> scan
    [iwd]# station <device-name> get-networks
    
  4. Connect to the network you desire (you will be prompted to enter a password if needed)

    [iwd]# station <device-name> connect <SSID>
    
  5. Exit iwctl

Test your internet connection by issuing a ping command to google.com, for example.

2. Time & Date

Sync time and date by running:

timedatectl

3. Create Partitions

I’m using fdisk here, but you can use any cli tool to partition the disk.

  1. List available disks

    fdisk -l
    

    Note down the disk you want to use (it will probably be /dev/nvme0n1). Also, note down the partition number for EFI System partition. We will need it later (it will probably be /dev/nvme0n1p1).

  2. Enter fdisk shell on the desired disk

    fdisk /dev/nvme0n1
    
  3. Create the partitions you want

In my case I went with root partition and a SWAP partition. You can ignore creating the SWAP partition and go with a swap file on the root partition. Consult Arch Wiki’s Swap page for this. Here is how I created my setup:

SWAP

Press n to create a new partition. Set swap size to 32GB, which is equivalent to the RAM size. An easy way to achieve this is to write +32G when asked for last sector.

Press t to set the type of the partition. Press L (this will show a list of partition types, you can use / to search through the list) and search for the number corresponding to type “Linux swap”. Then, enter this number for the partition type.

Note down the partition number for SWAP partition.

root

Press n to create a new partition. Set root size to the remaining of the disk. (i.e for last sector just hit <ENTER> to use the default value).

Press t to set the type of the partition. Press L (this will show a list of partition types, you can use / to search through the list) and search for the number corresponding to type “Linux root (x86-64)”. Then, enter this number for the partition type.

Note down the partition number for root partition.

Once you’re done, press w to write the changes.

Warning: Double check your changes. After you hit w, the the tool will write those changes and you can’t undo them.

4. Format the partitions

Formatting a partition means setting it up for use. This usually means creating the filesystem on the partition.

  1. Create ext4 filesystem for root partition

    mkfs.ext4 /dev/<root__partition>
    
  2. Setup swap for SWAP partition

    mkswap /dev/<swap_partition>
    

5. Mount filesystems and turn on swap

Now that we have created and formatted the partitions needed for the installation, we need to mount them into the current running boot image in order for us to be able to install the system.

  1. Mount root partition and UEFI System partition (the one you took note of in step 3.1)

    mount /dev/<root__partition> /mnt # Root partition
    mount --mkdir /dev/<efi_system_partition> /mnt/boot # UEFI partition
    
  2. Turn on swap

    swapon /dev/<swap_partition>
    

6. Install Arch

The command below installs base Arch Linux on the mounted filesystems. This will allow us to chroot into it and use the package manager.

pacstrap -K /mnt base

7. Generate an fstab file

fstab is a file used to give instructions on how to mount a partitions when the system boots. For more refer to arch Wiki’s fstab.

genfstab -U /mnt >> /mnt/etc/fstab

8. Chroot into the new system

arch-chroot /mnt

9. Set the timezone

ln -sf /usr/share/zoneinfo/<Region>/<City> /etc/localtime

10. Sync hardware clock with system clock

For more, check hwclock’s man page.

hwclock --systohc

11. Set the locale

  1. Uncomment en_US.UTF-8 UTF-8 (and any other locale you want) in /etc/locale.gen, then run:

    locale-gen
    
  2. Create file /etc/locale.conf setting LANG= to the locale you want. Example:

    echo 'LANG=en_US.UTF-8' > /etc/locale.conf
    

12. Create hostname

Create file /etc/hostname and add a hostname to it. Example:

echo 'musaad-laptop' > /etc/hostname

13. Setup users

  1. Set root user password

    passwd
    
  2. Create and set password for a non-root user

    useradd -m -g users -G wheel <username>
    passwd <username>
    

    -G wheel adds the user the group wheel. This group is used in sudo command, so it’s good to add sudo users to it.

14. Install essential packages

Even though we installed the base system, we still are missing essential packages. For example, the linux kernel is not yet installed.

The command below installs the linux kernel along with some essential packages:

pacman -S base-devel dosfstools mtools networkmanager sudo intel-ucode linux-firmware linux-lts linux-lts-headers grub efibootmgr posix sof-firmware

If a package is not known to you, you can use pacman -Si <package_name> to read more about it.

15. Enable NetworkManager

NetworkManager is a suite of networking tools to easily setup network connectivity for a system. For more, check NetworkManager. We need to enable NetworkManager so that it starts up when we boot the system.

systemctl enable NetworkManager

16. Configure GRUB

GRUB is bootloader. A boatloader is a program that is invoked by the BIOS, which then takes control of booting into the installed systems. GRUB can boot many systems (including Windows). For more on GRUB, checkout Arch Wiki’s GRUB page.

In step 14, we installed grub package. Now we need to add GRUB EFI application to the boot menu. This is how the BIOS becomes aware of GRUB.

  1. Mount UEFI system partition inside arch-chroot

    Yes, you have to mount it again within arch-chroot. This is because when we chroot-ed, we lost our previous mount points.

    mount /dev/<efi-partition> /boot
    
  2. Choose a boot loader identifier

    We need a name for the GRUB EFI boot menu entry. I named it “GRUB”, but you can choose whatever name you want. Run this command to install grub efi application.

    grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
    

    If you chose another name, then update the value of --bootloader-id= with the name you chose.

  3. Generate GRUB configuration file

    grub-mkconfig -o /boot/grub/grub.cfg
    

17. Shutdown and remove installation medium

  1. Exit chroot environment

    exit
    
  2. Umount all devices

    umount -a
    

    You can ignore warning messages that appear.

  3. Shutdown

    reboot --halt
    
  4. Remove the installation medium

Now we need to make sure that GRUB is the first entry in the boot menu, to do so:

  1. Power on the laptop, then when you see Thinkpad splash screen press <ENTER>, then press <F1> to Enter BIOS setup utility.

  2. Go to Setup -> Boot and double check that the first boot entry is GRUB, if not then drag it to the top.

  3. Press Save & Exit to exit the setup and boot the system.

That’s it, you’re all set! Now you can say “I use Arch, btw” 😁.

I the future, I will be updating this guide to include setting up more features related to the Thinkpad P14s Gen 5 (e.g. fingerprint reader).

References