The enthusiasm of Linux Kernel for supporting Ryzen mobile low-voltage CPU seems to match the popularity of the Ryzen laptops on the market. Although the Ryzen desktop CPU has been supported since Linux 4.11, the kernels whose version below 4.17 cannot perform normally on its mobile CPU. When I am writing this post (2018.07), the kernel version for most distributions is < 4.17 by default, so there are only several radical Linux distributions that can meet my demand, and Gentoo is one of them.
After going through the Gentoo Handbook, which is more friendly than before it was, I felt that there came a forceful excuse for me to ‘enjoy’ it this time. The interest to use Gentoo was intrigued
again 😂, so here comes the post to note several tips during installation.
Use Arch Linux installation image
The official installation image of rolling release provided by Gentoo does not support UEFI boot (2018.07). It does offer an image made in 2016 that supports UEFI boot. However, I know clearly that this image will not load successfully on my machine (the kernel is too old for Ryzen mobile), so using Arch Linux image with latest kernel might be the best choice.
You may want to know that Gentoo Handbook has been updated. “As of August 23, 2018 the official Minimal CDs are capable of booting in UEFI mode. Previous versions boot in BIOS (MBR) mode only. Readers looking to make their system UEFI bootable must download the latest ISO." As it mentions, the latest ISO supports UEFI boot. It is unnecessary to use Arch Linux installation image from now on.
Partitioning and prepare to use EFISTUB to boot
My scheme for partition obeys the Preparing the disks section of the Handbook, which is mounting the
/root partition onto
/mnt/gentoo and then referring to EFI system partition to mount the EFI partition on
/mnt/gentoo/esp and mount
In this way, the kernel files can be updated without needs to manually update the files in
/boot, at the same time, you keep the ESP partition tidy. You only need to use the old method. Copy the files in
Download Stage3 mirror
For information on the network configuration, see Network configuration
It is recommended to use the Links mentioned in the Handbook to download the Stage3 mirror. The Arch Linux image does not have Links built-in, so you should use pacman to install Lynx or Links to do this in the first place. My approach is to copy the pre-downloaded Stage3 image to the bootable disk in advance when creating the Arch Linux boot disk and then copy it to the
Modifying compile options
Add or change some options in make.conf to add support for Ryzen.
znverl which is required by Ryzen CPU should be put in the
-march. If your device works with Radeon VEGA GPU, you should add
radeonsi to the
VIDEO_CARDS option. Laptop users should turn on
Synaptics support. In addition, tuna 🐟's mirror is chosen to
GENTOO_MIRRORS for its satisfying speed. The
MAKEOPTS options follows the rule of the number of CPU cores plus 1. Take Ryzen 2700U as an example, i.e.
The following is an example of make.conf:
Information about other options can be found in Configuring compile options
Choose rsync mirrors
Curiosity drove me to go through the official Gentoo rsync mirrors page, but I didn’t find mirrors from China Mainland (2018.07), perhaps because of the existing mirrors of universities and companies in China Mainland haven’t meet the demands from Gentoo? It doesn’t say much for the speed of mirrors from Taiwan, China either. I found the rsync mirror by KAIST by accident. Although it only supports IPv4, it has very satisfactory performance. Let’s call it an unexpected discovery.
🎉 Congratulate TsingHua to host the only official rsync mirror certified by Gentoo Project in China Mainland (2019.01).
Mounting the necessary filesystems mentions that enabling systemd support requires the
--make-rslave parameter after
mount. The man page of the mount command indicates that this allows one to assign the directory with the propagation type of
-slave recursively by using
--make-rslave, i.e. the directory including all of its subdirectory alters with the master, but they do not notify the master of their change.
If you don’t use systemd, you can also add this option, so that you are not able to use
umount -R to force the partition to be unloaded.
When using eselect to select a profile, you need to pay attention to the kernel version. For Gentoo, the Linux kernel 4.17 at the time I am writing this (2018.07) is still an experimental kernel, so the options are near the bottom of the list.
If you attempt to install Gentoo in a minimal way as I do, you should choose the option requiring the fewest dependencies (that is, the option with the shortest text). In particular, avoid the option of having a desktop environment and it is not recommended to execute this task in the installation process even if it is needed later, so as to avoid overloading the CPU in a short period. No one is willing to cook their hands into roast ones by its own laptop 🔥.
Configuration of USE Flags
USE Flags is where the charm of Gentoo says 😎, which offers the possibility of streamlining the system, keeping the system tidy and maximizing efficiency. But its configuration is not done overnight. I tend to set a few global USE Flags and set local USE Flags for each package.
Although this is an achievement that needs to be maintained for quite a time, you can configure
-kde at the beginning to avoid unnecessary dependencies. In ordinary days, it is necessary to prevent installing softwares that rely on flags that have been banned such as Qt. In addition, the USE Flags page in the Handbook is a good way to take deeper look at it.
Manually compiling the kernel
Choosing genkernel is a painless way to compile the kernel, but that means the kernel won’t turn on options related with Ryzen. The conservative way should be to
genkernel all and then add the relevant kernel options and recompile the kernel. The disadvantage is that it costs time and resource, and the compiled kernel turns out to be huge.
First, install AMD Zen microcode by emerging linux-firmware
Don’t forget to install AMD GPUs drivers.
menuconfig to enable several options mentioned below to provide support for AMD Ryzen CPU and AMD GPUs, as well as kernel options related with EFI stub kernel.
Built-in kernel command line in Processor type and features needs to be filled in with paths to
Creating fstab file
If following configuration for EFISTUB above, state the binding mounts on the EFI partitionin fstab file. Here is an example:
blkid to get the file system UUID to replace its partition or device name is recommended. Remember not to miss the prefix
UUID=. If your SSD supports the
TRIM command, you can add the
discard to improve read/write performance. If your file system is Btrfs, the
ssd option is good to go, but according to the description of Optimization for SSD in the Btrfs Wiki TRIM/discard support is turned on by adding the
ssd option, and
ssd is also recommended for better compatibility.
Add UEFI boot entry
Talking about the UEFI boot entry, Gentoo Handbook and other distributions’ wikis recommend use efibootmgr to manage them. efibootmgr is simple and convenient indeed, but it is not able to recognize NVMe (Non-Volatile Memory express) device partitions.
/dev/nvme0n1p1is an illegal parameter to efibootmgr.
Since efibootmgr only has a soft spot for sda, I used the UEFI Shell to manually add entries to boot multiple operating systems.
Installing Wireless Network Related Packages
Then follow the Handbook to configure the network, and never forget to install the relevant package on the wireless network. Circling to look for network cables and humping at the corner by the router is not cool at all 😂
I have to say that if Ryzen has not given me a good enough excuse, maybe I wouldn’t install Gentoo Linux again. Anyway, thank you for offering me this wonderful experience. Hope that we can get well along in the next couples of months 💗