Skip to content

[Gentoo] There and back again

September 30, 2022 | 04:23 PM

OK - so I’m back on Gentoo 🐮. It’s not that BSD isn’t appealing. I just need a more robust desktop OS and FreeBSD has its share of short comings in that department. I’ll list the ones that ultimately resulted in my return to Gentoo because I imagine a future when these are no longer obstacles, and I come crawling back.

  1. No real support for gaming - not the kind I’m interested in anyway.
  2. Poor support for my peripherals (Apple Magic Trackpad).
  3. Unsupported platform by Widevine, which means no DRM content.

Table of contents

Open Table of contents

ZFS failure

I really did try to get ZFS working in Gentoo. It was something I really liked about FreeBSD so I wanted to bring that over as a learning. Unfortunately despite following along with Fearedbliss/Installing Gentoo Linux on ZFS I failed to get it working. That might have been because I don’t use grub, I just boot directly without any initramfs and configure my boot parameters via efimanager. You may have better luck if you follow the guide verbatim. I was bouncing between it and the Gentoo ZFS Wiki and it was a lot to juggle 😰.

Hello BTRFS

So I opted for the distant cousin to ZFS BTRFS. I got the impression there was a generalization about BTRFS that it was a shallow copy of ZFS and not worth using by comparison. If there is any merit to that, and I’m skeptical of there being any, it’s not immediately apparent as a casual user who just wants some snapshots.

I’ll put these up on GitHub but here’s any idea of how I am backing up Gentoo.

#!/bin/sh
#/etc/cron.daily/snapshot

DATE=$(date)
DOW=$(date +"%a")

if [ ! -e /mnt/snapshots ]; then
  mkdir -p /mnt/snapshots
fi

cd /
# clean up last week's snapshot
btrfs subvolume delete "/mnt/snapshots/${DOW}"

# create today's snapshot (read only)
/sbin/btrfs subvolume snapshot -r / "/mnt/snapshots/${DOW}"

# capture just the size of the snapshot
SIZE=`du -h -s /mnt/snapshots/${DOW} | sed 's/\t.*//'`

# overwrite the last system snapshot log
echo "Last system snapshot(${SIZE}): ${DATE}" > /var/log/last_snapshot

# update the MOTD
cat /var/log/last_backup    > /etc/motd
cat /var/log/last_snapshot >> /etc/motd

I also run weekly backups using rsync,

Configuration

Kernel make.conf

So much of installing Gentoo comes down to kernel options (if you’re not using a pre-built). I think this is one of the most appealing things about Gentoo for me, I’m a ‘tweaker’ at heart so turning off what I don’t use, and optimizing for what I do really speaks to my soul.

This is a double edged sword though, I spent a large amount of time getting my nVidia graphics card working correctly with the UEFI framebuffer 😡. More on that below!

Here is how I build my kernel configuration.

cd /usr/src/linux
make menuconfig .config
make && emerge @module-rebuild && make modules_install && make install
cp /boot/vmlinuz* /boot/efi/boot/bootx64.efi

I’ll share my kernel config on GitHub.

Microcode

I would recommend you do not overlook the microcode section of the wiki, it’s straight forward enough.

I’m on an Intel CPU so I took advantage of the iucode_tool as described in the Intel microcode guide.

# iucode_tool -S -l /lib/firmware/intel-ucode/* 
<...all of the bundles...>
selected microcodes:
  161/001: sig 0x000506e0, pf_mask 0x22, 2014-11-19, rev 0x0018, size 81920
  162/001: sig 0x000506e1, pf_mask 0x22, 2015-06-02, rev 0x002a, size 76800
  163/001: sig 0x000506e2, pf_mask 0x14, 2015-08-15, rev 0x002e, size 76800
  164/001: sig 0x000506e3, pf_mask 0x36, 2021-11-12, rev 0x00f0, size 109568
  165/001: sig 0x000506e8, pf_mask 0x22, 2016-07-10, rev 0x0034, size 96256

# iucode_tool -S -l /lib/firmware/intel-ucode/* | grep 163
  iucode_tool: system has processor(s) with signature 0x000506e3
microcode bundle 161: /lib/firmware/intel-ucode/06-5e-00
  161/001: sig 0x000506e0, pf_mask 0x22, 2014-11-19, rev 0x0018, size 81920

There were a lot of bundles spit out, so once I knew which were selected for my processor, I just used grep on the output again for the bundle identifier, which gave me the paths I needed to add to the CONFIG_EXTRA_FIRMWARE kernel parameter.

nVidia

This was a little finicky and it all comes down to framebuffers. When you boot up in UEFI the output is printed to an EFI framebuffer. The available options are not all compatible with my GeForce 1080 Ti when using nVidia’s proprietary drivers x11-drivers/nvidia-drivers. This isn’t a Gentoo problem, but if you’re going to select kernel options and you pick the wrong framebuffer it will either freeze up halfway through boot or boot to a black screen (though it is interactive, you just can’t see what you’re doing).

Here are the relevant options that should be set in the kernel configuration.

# CONFIG_DRM_SIMPLEDRM is not set
CONFIG_FB=y
CONFIG_DRM_NOUVEAU=m
CONFIG_DRM_KMS_HELPER=y

DRM_KMS_HELPER is an automatic dependency of DRM_NOUVEAU. I think two things are happening when I configure it this way. 🤷‍♂️

  1. The DRM_KMS_HELPER=y helps the kernel work out the correct mode setting for the video card.
  2. DRM_NOUVEAU=m, loads the open source nVidia driver module, which works well with UEFI framebuffers (as opposed to nVidia’s official drivers).

The result is I get text output all the way to my tty and nouveau is unloaded by the proprietary nVidia driver via blacklist nouveau during the sourcing of the /etc/modprobe.d/nvidia.conf which is installed by x11-drivers/nvidia-drivers. Leaving me in a good state when I start X.

Overlays

I needed to add a couple of overlays to get the software I wanted (ungoogled-chromium, steam, xrdp). This is easy to do with eselect and emaint.

🦈Overlay database

# eselect repository add pf4public git <url>
# emaint sync -r pf4public

Here are the ones I needed for my system.

#/etc/portage/repos.conf/eselect-repo.conf
# created by eselect-repo

[pf4public]
location = /var/db/repos/pf4public
sync-type = git
sync-uri = https://github.com/PF4Public/gentoo-overlay.git

[ace]
location = /var/db/repos/ace
sync-type = git
sync-uri = https://github.com/ananace/overlay

[steam-overlay]
location = /var/db/repos/steam-overlay
sync-type = git
sync-uri = https://github.com/gentoo-mirror/steam-overlay.git

Healthier hard drive

Based on the advice in the Gentoo wiki I did wind up creating a tmpfs folder, which acts as a ram-drive ⚡ and offloads all of the read/writes that occur during a build to memory rather than my poor SSD. I just create one on the fly when I’m going to emerge something.

#!/bin/sh
#~/bin/fast_emerge

# make a tmpfs for builds to use
sudo mount -t tmpfs tmpfs /var/tmp/portage/ -o size=8G,uid=portage,gid=portage,mode=775,nosuid,noatime
sudo emerge $@
sudo umount /var/tmp/portage/

I also clean up build dependencies every time I update.

#!/bin/sh
#~/bin/update 

sudo emaint --auto sync
sudo emerge --ask --verbose --update --deep --newuse @world
sudo emerge --ask --depclean --with-bdeps=y

I did more customization since which I’ll write about soon.