Home / About / The Way I Work / Gentoo Linux on a Thinkpad X13 AMD Gen 1

Installation Notes

Gentoo Linux on a Thinkpad X13AMD Gen 1

An archive of the steps taken to install and configure Gentoo Linux on a Thinkpad X13AMD Gen 1 using GNU+Linux. Last updated on 06 June 2021

OS: Gentoo/Linux x86_64
Host: 20UFCTO1WW ThinkPad X13 Gen 1
Kernel: 5.12.13-gentoo
Uptime: 14 mins
Packages: 1082 (emerge)
Shell: bash 5.1.8
Resolution: 1920x1080, 1920x1080
WM: dwm
Theme: Lounge [GTK2/3]
Icons: Blue-Maia [GTK2/3]
Terminal: lxterminal
Terminal Font: Hack 14
CPU: AMD Ryzen 7 PRO 4750U with Radeon Graphics (16) @ 1.700GHz
GPU: AMD ATI 06:00.0 Renoir
Memory: 617MiB / 31395MiB



Thinkpad X13 AMD Specs

THINKPAD X13 AMD Gen 1
X13 AMD Hardware Manual
X13 AMD User Guide
X13 AMD Platform Specifications



Installation Notes - Gentoo Linux


PREPARE THE DISK
root # cfdisk /dev/nvme0n1
/dev/nvme0n1p1  boot 	600M   	EFI
/dev/nvme0n1p2	/	953.3G 	Linux

FORMAT BOOT PARTITION
root # mkfs.fat -F 32 /dev/nvme0n1p1
LOAD THE DM-CRYPT MODULE
root # modprobe dm-crypt
CREATE LUKS VOLUME
root # cryptsetup luksFormat /dev/nvme0n1p2
root # cryptsetup --verbose --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random luksFormat /dev/nvme0n1p2
UNLOCK LUKS VOLUME
root # cryptsetup luksOpen /dev/nvme0n1p2 cryptmain
Enter your password.
You will now have access to your partition in /dev/mapper/cryptmain. Keep in mind the name “cryptmain” was chosen randomly and is just the name of the file that will represent the unlocked partition. You can change it every time you unlock it if you want.

CREATE THE PHYSICAL VOLUME AND VOLUME GROUP
root # pvcreate /dev/mapper/cryptmain
root # vgcreate vg /dev/mapper/cryptmain
CREATE TWO LOGICAL VOLUMES IN OUR NEW VOLUME GROUP [VGNAME].
root # lvcreate --size 4G --name swap vg
root # lvcreate --extents 100%FREE --name root vg
root # vgchange --available y
FIND THE REMAINING SPACE AVAILABLE WITH THE FOLLOWING COMMAND.
root # vgdisplay
If you look at the value for the field "PE Total" you will see how much space is available for allocation. Other fields can also be helpful to such as "allocated" and "free".

At this point you now have two logical volumes for swap and root respectively. You can now format them as you normally would.
root # mkswap /dev/mapper/vg-swap
root # mkfs.ext4 /dev/mapper/vg-root
At this point the rest of the gentoo handbook applies as normal.
root # swapon /dev/mapper/vg-swap

root # mount -t ext4 /dev/mapper/vg-root /mnt/gentoo
root # mkdir -p /mnt/gentoo/boot
root # mount -t vfat /dev/nvme0n1p1 /mnt/gentoo/boot
SET DATE AND TIME
root # date MMDDhhmmYYYY
Download and install stage3 into /mnt/gentoo Start sshd, set root passwd, create user and passwd
DOWNLOADING THE STAGE TARBALL
root # cd /mnt/gentoo
root # links https://www.gentoo.org/downloads/mirrors/
Move to the releases/amd64/autobuilds/ directory. There all available stage files are displayed (they might be stored within subdirectories named after the individual sub-architectures). Select one and press d to download.

VALIDATE THE DOWNLOAD
root # sha512sum stage3-amd64-.tar.?(bz2|xz)
UNPACK THE DOWNLOAD
root # tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
CONFIGURING COMPILE OPTIONS
root # nano -w /mnt/gentoo/etc/portage/make.conf
SELECTING MIRRORS
root # mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
Configuring the repository can be done in a few simple steps. First, if it does not exist, create the repos.conf directory:
root # mkdir --parents /mnt/gentoo/etc/portage/repos.conf
Next, copy the Gentoo repository configuration file provided by Portage to the (newly created) repos.conf directory:
root # cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

FILE: /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

[DEFAULT]
main-repo = gentoo
 
[gentoo]
location = /var/db/repos/gentoo
sync-type = rsync
sync-uri = rsync://rsync.gentoo.org/gentoo-portage
auto-sync = yes
sync-rsync-verify-jobs = 1
sync-rsync-verify-metamanifest = yes
sync-rsync-verify-max-age = 24
sync-openpgp-key-path = /usr/share/openpgp-keys/gentoo-release.asc
sync-openpgp-key-refresh-retry-count = 40
sync-openpgp-key-refresh-retry-overall-timeout = 1200
sync-openpgp-key-refresh-retry-delay-exp-base = 2
sync-openpgp-key-refresh-retry-delay-max = 60
sync-openpgp-key-refresh-retry-delay-mult = 4

COPY DNS INFO
One thing still remains to be done before entering the new environment and that is copying over the DNS information in /etc/resolv.conf. This needs to be done to ensure that networking still works even after entering the new environment. /etc/resolv.conf contains the name servers for the network.

To copy this information, it is recommended to pass the --dereference option to the cp command. This ensures that, if /etc/resolv.conf is a symbolic link, that the link's target file is copied instead of the symbolic link itself. Otherwise in the new environment the symbolic link would point to a non-existing file (as the link's target is most likely not available inside the new environment).
root # cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
MOUNTING THE NECESSARY FILESYSTEMS
root # mount -t proc /proc /mnt/gentoo/proc
root # mount --rbind /sys /mnt/gentoo/sys
root # mount --make-rslave /mnt/gentoo/sys
root # mount --rbind /dev /mnt/gentoo/dev
root # mount --make-rslave /mnt/gentoo/dev
CHROOTING
root # chroot /mnt/gentoo /bin/bash
root # source /etc/profile
root # export PS1="(chroot) $PS1"
INSTALLING A GENTOO EBUILD REPOSITORY SNAPSHOT FROM THE WEB
root # emerge-webrsync
CHOOSING THE RIGHT PROFILE
root # eselect profile list

Available profile symlink targets:
  [1]   default/linux/amd64/17.1 (stable)
  [2]   default/linux/amd64/17.1/selinux (stable)
  [3]   default/linux/amd64/17.1/hardened (stable)
  [4]   default/linux/amd64/17.1/hardened/selinux (stable)
  [5]   default/linux/amd64/17.1/desktop (stable) *
  [6]   default/linux/amd64/17.1/desktop/gnome (stable)
  [7]   default/linux/amd64/17.1/desktop/gnome/systemd (stable)


SELECT A PROFILE
root # eselect profile set 5
SYSTEM UPDATE
Updating the @world set
At this point, it is wise to update the system's @world set so that a base can be established.
root # emerge --ask --verbose --update --deep --newuse @world
TIME
root # echo "America/Chicago" > /etc/timezone
root # emerge --config sys-libs/timezone-data
LOCALE GENERATION
root # nano -w /etc/locale.gen
root # locale-gen
root # env-update && source /etc/profile && export PS1="(chroot) ${PS1}"
INSTALL KERNEL SOURCES
root # emerge --ask sys-kernel/gentoo-sources
root # emerge --ask sys-apps/pciutils

REMINDER
Make sure nm-applet and networkmanager both have use flag "modemmanager"
------------------------------------------------------------------------
Device Drivers  --->
  [*] Multiple devices driver support (RAID and LVM)  --->
    <*>   Device mapper support
    <*>     Crypt target support
-*- Cryptographic API  --->
  <*>   AES cipher algorithms (x86_64)

COMPILING AND INSTALLING
With the configuration now done, it is time to compile and install the kernel. Exit the configuration and start the compilation process:
root # make && make modules_install
root # make install

root # emerge cryptsetup

root # rc-update add sshd default
root # rc-update add dmcrypt boot
root # rc-update add lvm boot

root # emerge --ask sys-kernel/genkernel

root # genkernel --luks --lvm --install initramfs
root # nano -w /etc/fstab

#fstab
/dev/nvme0n1p1		/boot	vfat	noauto,noatime,discard	0 2
/dev/mapper/vg-root	/  	ext4	noatime				0 1
/dev/mapper/vg-swap	none	swap	sw					0 0
tmpfs				/tmp 	tmpfs	rw,nosuid,noatime,nodev,size=4G,mode=1777 0 0

HOST INFO
root # nano -w /etc/conf.d/hostname
CONFIGURING THE NETWORK
During the Gentoo Linux installation, networking was already configured. However, that was for the installation CD itself and not for the installed environment. Right now, the network configuration is made for the installed Gentoo Linux system.

All networking information is gathered in /etc/conf.d/net. It uses a straightforward yet perhaps not intuitive syntax. But don't fear, everything is explained below. A fully commented example that covers many different configurations is available in /usr/share/doc/netifrc-*/net.example.bz2.

FIRST INSTALL NET-MISC/NETIFRC:
root # emerge --ask --noreplace net-misc/netifrc
DHCP is used by default. For DHCP to work, a DHCP client needs to be installed. This is described later in Installing Necessary System Tools.

If the network connection needs to be configured because of specific DHCP options or because DHCP is not used at all, then open /etc/conf.d/net:
root # nano -w /etc/conf.d/net

FILE /etc/conf.d/net
Static IP definition
------------------------------------------------------------------------
config_eth0="192.168.0.2 netmask 255.255.255.0 brd 192.168.0.255"
routes_eth0="default via 192.168.0.1"

To use DHCP, define config_eth0:
FILE /etc/conf.d/netDHCP definition

config_eth0="dhcp"

AUTOMATICALLY START NETWORKING AT BOOT
To have the network interfaces activated at boot, they need to be added to the default runlevel.
root # cd /etc/init.d
root # ln -s net.lo net.eth0
root # rc-update add net.eth0 default
If the system has several network interfaces, then the appropriate net.* files need to be created just like we did with net.eth0.

If after booting the system we find out that the assumption about the network interface name (which is currently documented as eth0) was wrong, then execute the following steps to rectify this:

Update the /etc/conf.d/net file with the correct interface name (like enp3s0 instead of eth0).
Create new symbolic link (like /etc/init.d/net.enp3s0).
Remove the old symbolic link (rm /etc/init.d/net.eth0).
Add the new one to the default runlevel.
Remove the old one using rc-update del net.eth0 default.

HOSTS FILE
Next inform Linux about the network environment. This is defined in /etc/hosts and helps in resolving host names to IP addresses for hosts that aren't resolved by the nameserver.
root #nano -w /etc/hosts
FILE /etc/hosts
------------------------------------------------------------------------
# This defines the current system and must be set
127.0.0.1     tux.homenetwork tux localhost
  
# Optional definition of extra systems on the network
192.168.0.5   jenny.homenetwork jenny
192.168.0.6   benny.homenetwork benny

ROOT PASSWORD
Set the root password using the passwd command.
root # passwd
INIT AND BOOT CONFIGURATION
Review the settings and change where needed.
root # nano -w /etc/rc.conf
root # nano -w /etc/conf.d/keymaps
root # nano -w /etc/conf.d/hwclock
If the hardware clock is not using UTC, then it is necessary to set clock="local" in the file. Otherwise the system might show clock skew behavior.

SYSTEM LOGGER
root # emerge --ask app-admin/metalog
root # rc-update add metalog default
CRON DAEMON
root # emerge --ask sys-process/cronie
root # rc-update add cronie default
FILE INDEXING
In order to index the file system to provide faster file location capabilities, install sys-apps/mlocate.
root # emerge --ask sys-apps/mlocate
REMOTE ACCESS
To be able to access the system remotely after installation, add the sshd init script to the default runlevel:
root # rc-update add sshd default
FILESYSTEM TOOLS
Depending on the filesystems used, it is necessary to install the required file system utilities (for checking the filesystem integrity, creating additional file systems etc.). Note that tools for managing ext2, ext3, or ext4 filesystems (sys-fs/e2fsprogs) are already installed as a part of the @system set.

The tools to install if a certain filesystem is used:
-----------------------------------------------------------------------
Filesystem Package
Ext2,3, and 4 --------- sys-fs/e2fsprogs
XFS ------------------- sys-fs/xfsprogs
ReiserFS -------------- sys-fs/reiserfsprogs
JFS ------------------- sys-fs/jfsutils
VFAT (FAT32, ...) ----- sys-fs/dosfstools

INSTALLING A DHCP CLIENT
Gentoo recommends the use of net-misc/dhcpcd although many other DHCP clients are available through the Gentoo repository.

NetworkManger prefers DHCP:
root # emerge --ask net-misc/dhcp
Emerge
When using an older BIOS system supporting only MBR partition tables, no additional configuration is needed in order to emerge GRUB:
root # emerge --ask --verbose sys-boot/grub:2
A note for UEFI users: running the above command will output the enabled GRUB_PLATFORMS values before emerging. When using UEFI capable systems, users will need to ensure GRUB_PLATFORMS="efi-64" is enabled (as it is the case by default). If that is not the case for the setup, GRUB_PLATFORMS="efi-64" will need to be added to the /etc/portage/make.conf file before emerging GRUB2 so that the package will be built with EFI functionality:
root # echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf
root # emerge --ask sys-boot/grub:2
INSTALL
Next, install the necessary GRUB2 files to the /boot/grub/ directory via the grub-install command.
root # grub-install --target=x86_64-efi --efi-directory=/boot
CONFIGURE
Next, generate the GRUB2 configuration based on the user configuration specified in the /etc/default/grub file and /etc/grub.d scripts. In most cases, no configuration is needed by users as GRUB2 will automatically detect which kernel to boot (the highest one available in /boot/) and what the root file system is. It is also possible to append kernel parameters in /etc/default/grub using the GRUB_CMDLINE_LINUX variable.
FILE: /etc/default/grub
----------------------------------------------------------------------------------------------------------
GRUB_CMDLINE_LINUX="net.ifnames=0"
GRUB_CMDLINE_LINUX=dolvm crypt_root=/dev/sda2  real_root=/dev/mapper/vg-root rootfstype=ext4 root_trim=yes"

GENERATE THE FINAL GRUB2 CONFIGURATION:
root # grub-mkconfig -o /boot/grub/grub.cfg
REBOOT
root # exit
root # cd
root # umount -l /mnt/gentoo/dev{/shm,/pts,}
root # umount -R /mnt/gentoo
root # reboot
AFTER REBOOT
root # useradd -m -G users,wheel,audio -s /bin/bash rob
root # passwd rob


lspci Output

00:00.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir Root Complex 00:00.2 IOMMU: Advanced Micro Devices, Inc. [AMD] Renoir IOMMU 00:01.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir PCIe Dummy Host Bridge 00:02.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir PCIe Dummy Host Bridge 00:02.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Renoir PCIe GPP Bridge 00:02.2 PCI bridge: Advanced Micro Devices, Inc. [AMD] Renoir PCIe GPP Bridge 00:02.3 PCI bridge: Advanced Micro Devices, Inc. [AMD] Renoir PCIe GPP Bridge 00:02.4 PCI bridge: Advanced Micro Devices, Inc. [AMD] Renoir PCIe GPP Bridge 00:02.7 PCI bridge: Advanced Micro Devices, Inc. [AMD] Renoir PCIe GPP Bridge 00:08.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir PCIe Dummy Host Bridge 00:08.1 PCI bridge: Advanced Micro Devices, Inc. [AMD] Renoir Internal PCIe GPP Bridge to Bus 00:14.0 SMBus: Advanced Micro Devices, Inc. [AMD] FCH SMBus Controller (rev 51) 00:14.3 ISA bridge: Advanced Micro Devices, Inc. [AMD] FCH LPC Bridge (rev 51) 00:18.0 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 0 00:18.1 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 1 00:18.2 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 2 00:18.3 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 3 00:18.4 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 4 00:18.5 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 5 00:18.6 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 6 00:18.7 Host bridge: Advanced Micro Devices, Inc. [AMD] Renoir Device 24: Function 7 01:00.0 Non-Volatile memory controller: SK hynix Device 1639 02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 0e) 02:00.1 Serial controller: Realtek Semiconductor Co., Ltd. Device 816a (rev 0e) 02:00.2 Serial controller: Realtek Semiconductor Co., Ltd. Device 816b (rev 0e) 02:00.3 IPMI Interface: Realtek Semiconductor Co., Ltd. Device 816c (rev 0e) 02:00.4 USB controller: Realtek Semiconductor Co., Ltd. Device 816d (rev 0e) 03:00.0 Network controller: Intel Corporation Wi-Fi 6 AX200 (rev 1a) 04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS522A PCI Express Card Reader (rev 01) 05:00.0 USB controller: Renesas Technology Corp. uPD720202 USB 3.0 Host Controller (rev 02) 06:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Renoir (rev d1) 06:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Device 1637 06:00.2 Encryption controller: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh) Platform Security Processor 06:00.3 USB controller: Advanced Micro Devices, Inc. [AMD] Renoir USB 3.1 06:00.4 USB controller: Advanced Micro Devices, Inc. [AMD] Renoir USB 3.1 06:00.5 Multimedia controller: Advanced Micro Devices, Inc. [AMD] Raven/Raven2/FireFlight/Renoir Audio Processor (rev 01) 06:00.6 Audio device: Advanced Micro Devices, Inc. [AMD] Family 17h (Models 10h-1fh) HD Audio Controller


make.conf

# Please consult /usr/share/portage/config/make.conf.example for a more # detailed example. COMMON_FLAGS="-march=native -O2 -pipe" CFLAGS="${COMMON_FLAGS}" CXXFLAGS="${COMMON_FLAGS}" FCFLAGS="${COMMON_FLAGS}" FFLAGS="${COMMON_FLAGS}" # NOTE: This stage was built with the bindist Use flag enabled PORTDIR="/var/db/repos/gentoo" DISTDIR="/var/cache/distfiles" PKGDIR="/var/cache/binpkgs" # This sets the language of build output to English. # Please keep this setting intact when reporting bugs. LC_MESSAGES=C MAKEOPTS="-j9" VIDEO_CARDS="amdgpu radeonsi" INPUT_DEVICES="libinput wacom mouse keyboard" # USE="-consolekit -systemd -gnome -qt4 -qt5 -kde -obex -ldap \ alsa-plugin bluetooth elogind gtk xinerama pulseaudio networkmanager alsa X" # L10N="en" # # FEATURES="ccache" CCACHE_DIR="/var/cache/ccache" GENTOO_MIRRORS="http://www.gtlib.gatech.edu/pub/gentoo rsync://rsync.gtlib.gatech.edu/gentoo https://gentoo.osuosl.org/ http://gentoo.osuosl.org/ http://gentoo.mirrors.pair.com/ https://mirrors.rit.edu/gentoo/ http://mirrors.rit.edu/gentoo/ ftp://mirrors.rit.edu/gentoo/ rsync://mirrors.rit.edu/gentoo/ http://gentoo.cs.utah.edu/" GRUB_PLATFORMS="efi-64"


Kernel Config

Here is my config file for kernel-config-5.12.13-gentoo