Arch Linux on a Lenovo Thinkpad P52s
I installed Arch Linux on a Lenovo Thinkpad P52s using btrfs
for the filesystem and grub
for the bootloader. I recorded my process, beginning in a fresh installation image environment and ending with the root user booting into the new system.
I drew from several sources. The sources all have slightly different goals and focus areas. Most offer a useful generality this document may lack.
Partitions
Hopefully already well understood, but always worth mentioning, these instructions delete all data on the disk. Device names may vary by system.
fdisk /dev/nvme0n1
The fdisk
utility launches. It presents an interactive prompt.
Delete any existing partitions. Enter d and accept the default partition repeatedly until no partitions remain.
Create EFI partition. Enter n to create a new partition. Enter 1 for the partition number. Accept the default first sector. Enter +4G for the size. Then
fdisk
returns to its top-level prompt. Enter t to set the partition type. Enter 1 for the partition number. Enter uefi for the partition type.Create root partition. Enter n to create a new partition. Enter 2 for the partition number. Accept the default first sector. Accept the default size to use all remaining disk space.
Write changes. Optionally enter p to display the changes. Enter w to write the changes to disk. Then
fdisk
exits automatically.
Two new devices /dev/nvme0np1
and /dev/nvme0np1
exist now, and correspond to the two new partitions.
Filesystems
Format the root partition with a btrfs
filesystem to support snapshots. Ultimately only the subvolumes of this partition will be mounted, but for now temporarily mount it for the purpose of creating the subvolumes. Good candidates are parts of the filesystem that contain large or rapidly changing data unimportant for system restoration purposes. Create the subvolumes. The subvolumes appear under the partition's mount point as directories. Unmount the partition. Mount each of the subvolumes in its proper place. The noatime
option improves performance by not tracking access times on files.
# Format the root partition mkfs.btrfs /dev/nvme0n1p2 # Mount the partition temporarily mount /dev/nvme0n1p2 /mnt # Create subvolumes in the partition btrfs su cr /mnt/@ btrfs su cr /mnt/@home btrfs su cr /mnt/@root_btrsnap btrfs su cr /mnt/@tmp btrfs su cr /mnt/@var_cache btrfs su cr /mnt/@var_log btrfs su cr /mnt/@var_tmp # Umount the partition umount /mnt # Mount the subvolumes mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@ /dev/nvme0n1p2 /mnt mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@home /dev/nvme0n1p2 /mnt/home mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@root_btrsnap /dev/nvme0n1p2 /mnt/root/btrsnap mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@tmp /dev/nvme0n1p2 /mnt/tmp mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@var_cache /dev/nvme0n1p2 /mnt/var/cache mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@var_log /dev/nvme0n1p2 /mnt/var/log mount --mkdir -o noatime,compress=lzo,space_cache=v2,subvol=/@var_tmp /dev/nvme0n1p2 /mnt/var/tmp
Format the EFI parition with a FAT32 filesystem for compatibility with the firmware that will need to interact with it, and then mount the partition. The fmask
and dmask
options may help prevent certain nondescript boot issues I encountered.
mkfs.vfat -F32 /dev/nvme0n1p1 mount --mkdir -o fmask=0077,dmask=0077 /dev/nvme0n1p1 /mnt/efi
Installation
Connect to the internet wirelessly, replacing MyNetwork and MyPassphrase appropriately. Install the minimum necessary packages. Generate the fstab
file. This file remembers where we mounted everything.
iwctl --passphrase MyPassphrase station wlan0 connect MyNetwork pacstrap -K /mnt base linux linux-firmware genfstab -U /mnt >> /mnt/etc/fstab # Optionally take a snapshot btrfs su snapshot /mnt /mnt/root/btrsnap/0000.base
Configuration
Enter into the new installation. Install iwd
and openresolv
for internet access without help from the installation image, the text editor vim
for editing configuration files, and btrfs-progs
for taking system snapshots. Go through a number of mundane steps per the installation guide.
arch-chroot /mnt pacman -S iwd openresolv vim btrfs-progs # Set root password passwd # Create /etc/localtime (replace MyRegion and MyCity appropriately) ln -sf /usr/share/zoneinfo/MyRegion/MyCity /etc/localtime # I didn't read up on what this does hwclock --systohc # Uncomment the appropriate UTF-8 line, generate locale(s) vim /etc/locale.gen locale-gen
Bootloader
Install the necessary packages to make a grub
bootloader. Then install the bootloader and set up its configuration. Consider saving the bootloader installation and configuration lines as a script for later use.
pacman -S grub efibootmgr grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=arch_grub grub-mkconfig -o /boot/grub/grub.cfg # Optionally take a snapshot btrfs su snapshot / /root/snapshots/0001.configure
Reboot
Exit out of the chroot
, unmount all the filesystems, and restart the system.
# Back in the installation image environment umount -R /mnt reboot
Remove the installation media and restart the laptop. If all goes well log in as root.
References
- Authoritative and comprehensive, but also branches off in many directions. Complimentary resources demonstrating specific paths through the installation process can help.
- Primary resource after exploring many avenues because it treats an unencrypted
btrfs
filesystem. Concludes with a discussion of video drivers and preparation for playing games. - Uses
ext4
filesystems, but features an encrypted/home
partition. Discussesdocker
configuration, and measures to ensure the compatibility of the installation with wake-on-lan. - Single encrypted
btrfs
filesystem. Built insystemd
bootloader instead ofgrub
. Splash screen on startup and shutdown usingplymouth
. Covers setting up secure boot and hibernate. - Discusses swap partitions and the practices surrounding them that several major Linux distributions have landed on. Also contains useful information about memory usage and monitoring.
- Flow of control passes through a bootloader and an initial ramdisk before reaching the Linux kernel. Contributors discuss and critique why these components exist and what they do.