Thinkpad E14 Gen2: Linux setup
Some common fixes for issues I’ve ran into with Arch Linux on the Thinkpad E14 Gen2, regarding hibernate and sleep. This guide assumes you are using BTRFS and grub boot-loader.
Fixing unresponsive trackpoint after waking from sleep/hibernate
Edit: /usr/lib/systemd/system-sleep/10-trackpoint-reload.sh
#!bin/sh
case $1/$2 in
post/*)
# Reload input drivers after waking from sleep or hibernate
/usr/sbin/modprobe -r elan_i2c psmouse
/usr/bin/sleep 0.5
/usr/sbin/modprobe psmouse elan_i2c
;;
esac
Make sure it’s an executable: sudo chmod +x /usr/lib/systemd/system-sleep/10-trackpoint-reload.sh. And it should work!
System hibernation
Create the swap btrfs subvolume if it doesn’t exist already.
sudo mkdir -p /mnt/btrfs-root
sudo mount -o subvolid=5 /dev/mapper/root /mnt/btrfs-root
sudo btrfs subvolume create /mnt/btrfs-root/@swap
sudo umount /mnt/btrfs-root
sudo rm -rf /mnt/btrfs-root
Append the following to /etc/fstab:
# BTRFS Swap Subvolume
UUID=[YOUR_BTRFS_ROOT_UUID] /swap btrfs subvol=@swap,nodatacow,noatime 0 0
# Hibernation swapfile
/swap/swapfile none swap defaults 0 0
Create the swapfile used for system hibernation. Please note: I use a swap size of 16G, which matches my total size of RAM. Ensure to use your RAM size.
sudo systemctl daemon-reload
sudo mkdir -p /swap
sudo mount /swap
sudo truncate -s 0 /swap/swapfile
sudo chattr +c /swap/swapfile
sudo btrfs property set /swap/swapfile compression none
sudo fallocate -l 16G /swap/swapfile
sudo chmod 600 /swap/swapfile
sudo mkswap /swap/swapfile
sudo swapon /swap/swapfile
Inspect the swapfile to find underlying offset:
sudo btrfs inspect-internal map-swapfile -r /swap/swapfile
Copy the value displayed, this value will be used for grub’s resume_offset to properly resume hibernate.
Edit /etc/default/grub and append the following attributes inside of GRUB_CMDLINE_LINUX_DEFAULT="":
resume=UUID=[YOUR_BTRFS_ROOT_UUID] resume_offset=[COPIED_SWAP_OFFSET_VALUE]
Regenerate the grub config to apply these changes.
sudo grub-mkconfig -o /boot/grub/grub.cfg
The final step is the mkinitcpio hook for resuming hibernation.
Edit /etc/mkinitcpio.conf inside of Hooks=() add resume. The order here matters, if you have an encrypted filesystem, place it after the encrypt hook. If not, you may place it between block and filesystems hooks.
Now apply these new settings:
sudo mkinitcpio -P
sudo reboot
You may now test hibernate by running: sudo systemctl hibernate
Deep sleep setup
Check if you already have deep sleep enabled:
cat /sys/power/mem_sleep
s2idle [deep] if deep has brackets around it like this, you already have deep sleep setup. If not, follow these steps below.
Enter into the BIOS. Under the power settings, set sleep mode to Linux S3.
Edit /etc/default/grub and inside of GRUB_CMDLINE_LINUX_DEFAULT="" add mem_sleep_default=deep.
Reboot your system and follow the first step again to ensure deep sleep is properly enabled.
