Skip to content

Instantly share code, notes, and snippets.

@Obihoernchen
Last active March 12, 2024 01:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Obihoernchen/973edb3618ed87a91e4af29d9484e804 to your computer and use it in GitHub Desktop.
Save Obihoernchen/973edb3618ed87a91e4af29d9484e804 to your computer and use it in GitHub Desktop.

Fedora 34+ on Lenovo ThinkPad P14s Gen 2 AMD

Specifications

System:    Host: obi-notebook Kernel: 5.13.19-200.fc34.x86_64 x86_64 bits: 64 Desktop: GNOME 40.4
           Distro: Fedora release 34 (Thirty Four) 
Machine:   Type: Laptop System: LENOVO product: 21A00004GE v: ThinkPad P14s Gen 2a 
           Mobo: LENOVO model: 21A00004GE UEFI: LENOVO v: R1MET39W (1.09 ) date: 06/21/2021 
Battery:   ID-1: BAT0 charge: 42.6 Wh (79.5%) condition: 53.6/50.5 Wh (106.3%) 
Memory:    RAM: total: 27.23 GiB used: 2.61 GiB (9.6%) 
           Array-1: capacity: 64 GiB slots: 2 EC: None 
           Device-1: DIMM 0 size: 16 GiB speed: 3200 MT/s 
           Device-2: DIMM 0 size: 16 GiB speed: 3200 MT/s 
CPU:       Info: 8-Core AMD Ryzen 7 PRO 5850U with Radeon Graphics [MT MCP] speed: 1334 MHz min/max: 1600/1900 MHz 
Graphics:  Device-1: Advanced Micro Devices [AMD/ATI] Cezanne driver: amdgpu v: kernel 
           Device-2: IMC Networks Integrated Camera type: USB driver: uvcvideo 
           Display: server: X.Org 1.21.1.2 driver: loaded: amdgpu note: n/a (using device driver) 
           resolution: 3840x2160~60Hz 
           OpenGL: renderer: AMD RENOIR (DRM 3.41.0 5.13.19-200.fc34.x86_64 LLVM 12.0.1) v: 4.6 Mesa 21.1.8 
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet driver: r8169 
           Device-2: Intel Wi-Fi 6 AX210/AX211/AX411 160MHz driver: iwlwifi *
           Device-3: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet driver: r8169 
Bluetooth: Device-1: Intel AX210 Bluetooth type: USB driver: btusb *
Drives:    Local Storage: total: 953.87 GiB used: 39.84 GiB (4.2%) 
           ID-1: /dev/nvme0n1 vendor: SK Hynix model: HFS001TDE9X081N size: 953.87 GiB 
Info:      Processes: 420 Uptime: 24m Memory: 27.23 GiB used: 2.56 GiB (9.4%) Shell: Zsh inxi: 3.3.06 

* originally Realtek 8852AE (see WIFI)

General notes

WIFI

The installed M.2 Realtek WIFI chip 8852AE sucks. It's slow and driver support is not in mainline kernel yet. Get a better Intel AX200 or AX210 WIFI chip for 10-15€. However, the kernel still needs to be updated for Intel AX210 to work out-of-the-box. For more details see: https://gist.github.com/linderd/71ec30048e78813115ba3f634e1b0817#wlanwifi

UEFI settings

For Linux suspend to work, set the following in UEFI:

Config -> Energy-Optimization -> select Linux instead of Windows 10

Display backlight control

Display backlight control did not work with stock Fedora 34 kernel. After a kernel upgrade everything worked as expected.

Windows dual boot with BitLocker and LUKS

Enable encryption on both Windows and Linux using BitLocker and LUKS. Furthermore, mount the encrypted NTFS partition in Linux automatically. Windows will soon be able to mount the LUKS encrypted Linux partitions via WSL2, too.

Initial installation

  • Enable Windows BitLocker
  • Save BitLocker recovery key: Control Panel -> System Security -> BitLocker Drive Encryption -> Backup your recovery key -> Save to a file
  • Shrink C:\ partition using Windows Disk Management
  • Install Fedora via USB flash drive
    • Choose empty space for installation
    • Enable LUKS encryption
    • Default settings work just fine

Mount BitLocker encrypted NTFS partition in Linux

  • Read your BitLocker recovery key file and copy&paste the recovery key to unlock the Windows partition via Linux file explorer
  • Configure NTFS usermapping
    • Unmount Windows file system
    • sudo ntfsusermap /dev/mapper/bitlk-<id> (just map your Windows user)
    • Mount Windows file system
    • Copy created config to file system: sudo mkdir /windows/.NTFS-3G && sudo mv UserMapping /windows/.NTFS-3G
  • Enable Windows partition unlock on startup using systemd-cryptsetup
    • Copy BitLocker recovery key to a plain text file with 600 permissions. For instance: /etc/cryptsetup/bitlocker
    • Add the following line to your /etc/crypttab file (get PARTUUID with sudo blkid command):
      bitlk-<id> PARTUUID="<PARTUUID>" /etc/cryptsetup/windows_bitlocker.key bitlk,discard
      
  • Mount Windows file system on startup using Gnome Disks
    • Edit mount options
    • Uncheck Use Session Defaults
    • Set the following mount options: nosuid,nodev,nofail,x-gvfs-show,windows_names,big_writes

Mount LUKS encrypted Linux partition in Windows

TODO coming soon: https://docs.microsoft.com/en-us/windows/wsl/wsl2-mount-disk

References

Bigger fonts for 4K screen

Grub2 and console font on the 4K screen is way too small and unreadable. Fix as shown below.

grub2 font

Create font for grub.

sudo grub2-mkfont --output=/boot/efi/EFI/fedora/fonts/DejaVuSansMono32.pf2 --size=32 /usr/share/fonts/dejavu-sans-mono-fonts/DejaVuSansMono.ttf

Set new custom font in /etc/default/grub.

# CUSTOM FONT
GRUB_TERMINAL_OUTPUT="gfxterm"
GRUB_FONT="/boot/efi/EFI/fedora/fonts/DejaVuSansMono32.pf2"

Update grub config.

sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg # for UEFI boot
sudo grub2-mkconfig -o /boot/grub2/grub.cfg          # for BIOS boot

console font

Available fonts can be found in /usr/lib/kbd/consolefonts/.

Edit /etc/vconsole.conf and set:

FONT="latarcyrheb-sun32"

Append vconsole.font=latarcyrheb-sun32 to GRUB_CMDLINE_LINUX in /etc/default/grub.

GRUB_CMDLINE_LINUX="[...] rhgb quiet vconsole.font=latarcyrheb-sun32"

Update grub config.

sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg # for UEFI boot
sudo grub2-mkconfig -o /boot/grub2/grub.cfg          # for BIOS boot

References

Shell config

https://github.com/Obihoernchen/shell-config

Remmina HiDPI fix

Chrome and vscode multiple displays with different scaling issue

Non native Wayland applications do not scale properly if there are multiple displays with different scaling.

  • Set vscode setting: "window.titleBarStyle": "custom"
  • Create script to start chrome and vscode with native wayland support and use it for every system update
#!/bin/bash

sudo dnf update --refresh

# Native Wayland support
#files=(/usr/share/applications/code.desktop /usr/share/applications/code-url-handler.desktop /usr/share/applications/google-chrome.desktop)
# Chrome now via chrome://flags/#ozone-platform-hint Auto
files=(/usr/share/applications/code.desktop /usr/share/applications/code-url-handler.desktop)
for i in ${files[@]}; do
	if ! grep -q '\-\-enable-features=UseOzonePlatform \-\-ozone-platform=wayland' "$i"; then
		echo "Patching wayland support: $i"
		sudo sed -i -E 's/^Exec=\S+/& --enable-features=UseOzonePlatform --ozone-platform=wayland/' "$i"
	fi
done

Blurry chrome in Gnome 44

Disable the new chrome feature WaylandFractionalScaleV1

if ! grep -q '\-\-disable-features=WaylandFractionalScaleV1' "/usr/share/applications/google-chrome.desktop"; then
	sudo sed -i -E 's/^Exec=\S+/& --disable-features=WaylandFractionalScaleV1/' "/usr/share/applications/google-chrome.desktop"
fi

Reference: https://bugs.chromium.org/p/chromium/issues/detail?id=1356014

Automatically change sensitivity for USB mouse

Create file /etc/udev/rules.d/71-mousespeed.rules and replace <YOUR_USER> with your username.

# Change sensitivity for USB mouse

# Ignore touchpad and trackpoint
SUBSYSTEMS=="serio", GOTO="mousespeed_end"

# USB mouse speed
ACTION=="add", KERNEL=="mouse[0-9]*", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", RUN+="/usr/sbin/runuser -l <YOUR_USER> -c '/usr/bin/gsettings set org.gnome.desktop.peripherals.mouse speed 0.0'"
# Touchpad/Trackpoint speed
ACTION=="remove", KERNEL=="mouse[0-9]*", SUBSYSTEM=="input", ENV{ID_INPUT_MOUSE}=="1", RUN+="/usr/sbin/runuser -l <YOUR_USER> -c '/usr/bin/gsettings set org.gnome.desktop.peripherals.mouse speed -0.4'"

LABEL="mousespeed_end"

Post install

Git config

git config --global user.name "<Name>"
git config --global user.email "<Mail>"
git config --global pull.rebase true

Setup automount

In /etc/fstab

# Home NAS
//192.168.0.1/NAS/SSD /mnt/Home/NAS/SSD smb3 credentials=/etc/mount_home.cred,uid=1000,gid=1000,noserverino,file_mode=0644,dir_mode=0755,nofail,noauto,_netdev,x-systemd.automount,x-systemd.mount-timeout=10s,x-systemd.idle-timeout=600s 0 0
# Company
//192.168.X.Y/vertrieb /mnt/Company/X/Y smb3 credentials=/etc/mount_company.cred,uid=1000,gid=1000,file_mode=0644,dir_mode=0755,nostrictsync,actimeo=10,cache=loose,nofail,noauto,_netdev,x-systemd.automount,x-systemd.mount-timeout=10s,x-systemd.idle-timeout=600s 0 0

Fix VirtualBox kernel module loading

Module needs to be signed for secure boot. Follow steps from /usr/share/doc/akmods/README.secureboot.

Note: A real shutdown (boot cycle) was necessary. A reboot was not enough

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment