The enthusiasm of the Linux kernel to follow up with support for AMD Ryzen™ mobile low-voltage CPUs seems to match the enthusiasm of the few AMD Ryzen™ laptops on the market. While AMD Ryzen™ desktop CPUs have been better supported since Linux 4.11, kernels below 4.17 do not even load properly on their mobile CPUs. At the time of writing (2018.07), most distributions have < 4.17 as their default kernel version, so the few radical Linux distributions that exist are my only options, and Gentoo is one of them.
After going through the Gentoo Handbook, which is much more friendly than the previous one, and with the need to toss it around, I decided to use Gentoo. So my interest in using Gentoo was ignited again 😂, and I have documented a few installation tips in this article.
Installing images with Arch Linux
The official rolling update install image provided by Gentoo does not support UEFI booting. It does provide a UEFI-compatible image from 2016. However, I know that this image will not load properly on my device (the kernel is too old for AMD Ryzen™ mobile platforms), so using the Arch image with the latest kernel seems to be the best option.
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 preparing to boot with EFISTUB
My partitioning scheme is to follow the Preparing the disks section of the Handbook, mount the
/root partition to
/mnt/gentoo and refer to EFI system partition to mount the EFI partition to
/mnt/gentoo/esp and then
This way, while keeping the ESP partition tidy, there is no need to manually update the files in
/boot after the kernel files have been updated. All you need to do is copy the set of files in
/esp/EFI/Gentoo the old way.
Downloading the Stage3 image
See Network configuration for the network configuration section.
The Handbook recommends using Links to access the mirrors to download the Stage3 image; the Arch Linux image does not come with Links, so you should first install Lynx or Links using pacman to do this. I did this by copying the downloaded Stage3 image to the boot disk and then to the
/mnt/gentoo directory when I made the Arch Linux boot disk.
Modify precompilation parameters
You need to add or change some parameters in
make.conf to add support for AMD Ryzen™.
CFLAGS is a mandatory parameter for AMD Ryzen™ CPUs. If the device uses Vega’s GPU, then the
radeonsi should be added. Laptop users should add Synaptics support. In addition to that, the very fast Tuna 🐟 is chosen for
GENTOO_MIRRORS and the
MAKEOPTS parameter follows the CPU core count plus one, i.e.
-j5 in the case of AMD Ryzen™ 2700U.
The following is an example of a complete
Information about other options can be found in Configuring compile options
Rsync Mirrors selection
Gentoo allows the address of the rsync mirror server to be specified by editing the configuration file of the portage repository. You can of course choose either the tuna or USTC source.
Curiosity led me to look through the official Gentoo page Gentoo rsync mirrors, but I did not find any mirrors from mainland China, perhaps because the existing mirrors from mainland China, both university and enterprise, do not reach Gentoo. Perhaps because the existing mirrors from mainland China, whether universities or enterprises, do not meet Gentoo’s standards. However, the speed of Taiwan’s sources in mainland China is hard to be complimented. I accidentally found the rsync source provided by KAIST. Although it only supports IPv4, the speed is very satisfactory. This is an unexpected discovery.
🎉 Congratulations to Tsinghua University for being the only available rsync mirror in mainland China, now that’s a better choice (2019.01).
Mounting the necessary filesystems, it is mentioned that enabling Systemd support requires
-mount followed by the
-make-rslave argument. The man page of the
mount command indicates that this will recursively give the directory the propagation type of
slave, i.e. the directory, including all its subdirectories, will follow
master changes without notifying itself when it changes and does not notify
master of changes when it changes itself.
If you are not using Systemd, you can also add this parameter so that you cannot use
umount -R to forcibly unmount the partition.
Selecting a Profile
eselect to select a profile, it is important to keep an eye on the kernel version. For Gentoo, at the time of writing (2018.07) the 4.17 version of the Linux kernel is still an experimental kernel, so the options are at the bottom of the list.
If, like me, you intend to install Gentoo minimally, you should choose the option with the fewest additional installation items (i.e., the shortest text). In particular, avoid the option with the desktop environment, even if you need it later, and it is not recommended to place this task in the installation process to avoid overloading the CPU with work for a short period of time. People don’t want their laptops to personally cook their hands into ironclad dog paws.
Configuration of USE Flags
USE Flags is the beauty of Gentoo, it offers the possibility to streamline the system, helping to keep it simple and maximize efficiency. But its configuration is not a quick fix. I tend to set fewer global USE Flags, and local USE Flags for each package.
This is a result of a certain amount of maintenance time, but at the beginning you can also configure
-kde to avoid some unnecessary dependencies. In addition, the USE Flags page in the Handbook is a good place to get a deeper understanding.
Manually compiling the kernel
genkernel is a relatively painless way to compile the kernel, but it means that the kernel will not be able to turn on AMD Ryzen™ related parameters. A conservative approach would be to
genkernel all and then add the relevant kernel parameters and recompile the kernel once more. The disadvantage of this approach is that it is time and resource consuming, and the compiled kernel is not small and elegant.
Start by installing the AMD Zen microcode via
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
About Ryzen, AMDGPU and AMD_microcode of the chapters in the Handbook provide a great deal of help for working on the content of this section.
Creating fstab file
If following configuration for EFISTUB above, state the binding mounts on the EFI partition in fstab file. Here is an example:
It is recommended to use
blkid to get the respective UUID of the file system to replace its partition or device name, remembering to add the
UUID= prefix. If the SSD supports TRIM commands, you can add the
discard to improve its read/write performance. If you are using Btrfs as a file system, you can add the
ssd, but according to the Btrfs Wiki on [optimization for SSD](https://btrfs.wiki.kernel.org/index.php/FAQ#Is_Btrfs_ optimized_for_SSD.3F), adding the
ssd parameter will not support TRIM/discard, and the official recommendation is to use
ssd for better compatibility.
Add UEFI boot portal
For the UEFI boot portal, the recommendation of the Gentoo Handbook and other distribution wikis is to use efibootmgr to manage it. efibootmgr is really simple and convenient, but it does not recognize nvme device partition information, e.g.
/dev/nvme0n1p1 is an illegal disk parameter. Since efibootmgr has a fondness for
sda, I added the entry manually using the Shell according to the section UEFI Shell.
Installing wireless network related packages
After configuring the network according to the Handbook, don’t forget to install the wireless network related packages, it won’t be elegant to look around for a network cable and crouch by the router 😎.
That said, I probably wouldn’t have gotten on board with Gentoo if AMD Ryzen™ hadn’t given me a good reason to do so. Either way, thanks for the wonderful experience. Stay tuned for the next few months 💗