heap.ovh

embedded adventures

Running Gentoo on HP t520, part 2

Continued from Part 1

My particular unit came with 4GiB RAM and 16 GiB M.2 SATA which is not that much to work with. While installing Gentoo on such a low-powered device is questionable at best I have been curious about it for a while and decided to give it a shot.

To make it more feasible a certain set of expectations needs to be defined in advance:

  • single-user device
  • not encrypted
  • primary use: HTPC
  • no multilib
  • minimal set of USE flags
  • balanced CFLAGS
  • KISS

Installation

For the installation I followed the AMD64 installation handbook which was informative and to the point.

As I do not intend to use any 32 bit software I chose the basic no multilib profile. For CFLAGS I decided to go with rather conservative -march=btver2 -O2 -pipe -ftree-vectorize to take full advantage of the CPU's capabilities. I intend to use a GTK+ based desktop manager (XFCE) so initially I picked the following USE flags:

:::
USE="-qt5 -kde -tk -doc -gtk-doc -postscript -cups opengl alsa cairo consolekit dbus jpeg png svg libnotify startup-notification vdpau"

I need to be very zealous and frugal with both global and local USE flags and the dependencies they pull due to the slow hardware. This will somewhat limit my choices as described in the software section below.

In order to take advantage of the amdgpu kernel driver VIDEO_CARDS was set appropriately to "amdgpu radeonsi".

To keep the system as simple a possible I decided against using initrd and chose to boot the kernel directly from EFI. Consequently, I created the EFI System Partition and followed the instructions at EFI stub kernel. Interestingly, using efibootmgr is not strictly required. Placing the kernel image under EFI/Boot/bootx64.efi is enough for the firmware to pick it up. However, this necessitates building in the kernel command line (including root= and other optional parameters). The alternative is using efibootmgr and creating a new boot entry for the firmware which can pass additional arguments to the kernel. Here I hit some kind of encoding relatated snag as apparently -u switch is required to pass the arguments in unicode, otherwise the kernel command line will be garbled. The second thing to remember is that efivarfs needs to be remounted rw before efibootmgr can modify it (mount /sys/firmware/efi/efivars -o rw,remount).

Software and configuration

Last time I tried 'linux on a desktop' was about 5 years ago. To try something familiar and see how much it has changed I decided to emerge Xfce 4.13 which is the development version for Xfce 4.14 which has been nearing realease (for a while now). To make it easy to install and manage, I created a local xfce4-meta ebuild pulling in development versions of xfce components:

:::
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

DESCRIPTION="The Xfce Desktop Environment (meta package)"
HOMEPAGE="https://www.xfce.org/"
SRC_URI=""

LICENSE="metapackage"
SLOT="0"
KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~sparc x86 ~x86-fbsd ~amd64-linux ~x86-linux"
IUSE="minimal +svg"

RDEPEND=">=x11-themes/gtk-engines-xfce-3:0
    x11-themes/hicolor-icon-theme
    >=xfce-base/xfce4-appfinder-4.13.2
    >=xfce-base/xfce4-panel-4.13.4
    >=xfce-base/xfce4-session-4.13.1
    >=xfce-base/xfce4-settings-4.13.5
    >=xfce-base/xfdesktop-4.13.3
    >=xfce-base/xfwm4-4.13.1-r2
    xfce-extra/xfce4-notifyd
    !minimal? (
            media-fonts/dejavu
            virtual/freedesktop-icon-theme
            )
    svg? ( gnome-base/librsvg )"

The graphics stack would be xorg-server 1.20.4, mesa 18.3.6 and xf86-video-amdgpu 19.0.1 built with llvm 7.1.0. This all works pleasantly well (Xorg.log available). One issue I encountered is that rapid mouse movements cause some CPU spikes but this might be a limitation of the xorg server architecture (to be investigated).

As the primary use of the device is playing movies, I emerged mpv with VDPAU support. Hardware video acceleration on the amdgpu driver works very well and AVC 1080p playback was buttery smooth. Audacious serves as a music player.

I have not quite solved the problem of picking the right web browser. Both Firefox and Chromium are too large to be built natively. I am not interested in Google Chrome binary and a pre-built Firefox binary pulls quite a few dependencies (including pulseaudio) and lacks hardware acceleration which would render it slow. Older single-purpose browsers such as surf or uzbl ceased development and WebKitGTK+ comes with some bizzare dependencies of its own (ruby?). The same applies to midori and epiphany. As a temporary solution I decided to install a nightly snapshot of Servo although it only works for simple pages such as wikis while failing at anything more complex (youtube, reddit etc).

The complete list of explicitely installed packages is currently quite short.

Bugs

The only thing that doesn't appear to be working is suspend-resume. The device suspends but fails to wake up (screen remains blank).

Final thoughts

Installing Gentoo was more straightforward than I anticipated, in large part due to good documentation. However, it does seem a bit fragmented, for example EFI configuration is covered by several separate wiki pages (Handbook, efibootmgr, EFI stub kernel, EFI System Partition etc). Similar fragmentation can be seen in utilities and system helper tools (portage, eix, q-tools, equery etc) which takes some time getting used to. Overall I am quite happy with how it turned out.