Dorion Mode

December 24, 2020

A Gentoo install on JWRD desktop

Filed under: JWRD — Tags: — Robinson Dorion @ 18:14

I managed to install Gentoo on my JWRD desktop with the software in the table below. Below the table I've documented the steps I took and the commands I issued to beat this thing into shape. I've included various example configs, adjust to suit your needs.

Part Make & Model
Compiler GCC 4.9.4
C library and linking method glibc 2.23 dynamic1
Kernel Linux 4.92
Coreutils binutils 2.25.13
Boot loader Lilo 24
Graphical Environment X11 1.19
Masterclass in Economy Eulora v1

1. Flash USB stick with Gentoo install env and boot

Obtain an install ISO from Gentoo and run :

dd if=/path/to/image.iso of=/dev/sdc bs=8192k

2. Modify BIOS to boot into USB

My BIOS menu is accessed by hitting F2 on boot. I enabled legacy boot mode4, then hit F8 to select the inserted USB as boot media.

3. Format the disk partitions and make filesystems.

fdisk -t dos /dev/sda

In fdisk, punch the p key to print the partition table, the m key for help and the a key to toggle a bootable flag on partition 1. I made 3 partitions leaving 100 GB of my 2 TB disk unpartitioned.

1 125M /boot
2 25G /
3 1874.875G /home

When you've got everything set, the w key writes your work to disk and exits.

mkfs.ext4 /dev/sda{1,2,3}

4. Mount your disks and install some Gentoo files.

mount /dev/sda2 /mnt/gentoo
cd /mnt/gentoo
tar xjvf /path/to/stage3-amd64-20170316.tar.bz2
cd usr
tar xjvf /path/to/portage-amd64-multilib-20170627.tar.bz2
mount /dev/sd1 /mnt/gentoo/boot

I installed the following :

/mnt/gentoo/etc/portage/make.conf
/mnt/gentoo/etc/portage/package.mask/crapolade
/mnt/gentoo/etc/portage/package.use/use.flags

While -suid is set in make.conf, it's enabled for x11-base/xorg-server in use.flags to allow starting X from non-root users.

I used those CFLAGS in make.conf to match the AMD Piledriver architecture of my CPU, adjust to fit your gear.

CFLAGS="-march=bdver2 O2 -pipe"

For the initial install, you may want DNS because if the GENTOO_MIRRORS in your make.conf don't have the specific package you're looking for, portage will try some additional mirrors whose URLs it resolves with DNS. If you don't need DNS and can manage purely on a /etc/hosts basis, more power to you.

cp /etc/resolv.conf /mnt/gentoo/etc/

5. Enter the chroot

mount -t proc proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev/ /mnt/gentoo/dev

chroot /mnt/gentoo /bin/bash
source /etc/profile
export $PS1="(chroot) $PS1"

6. Set profile, time and locale, and proper Python

eselect profile list
[X] default/linux/amd64/13.0

echo "UTC" > /etc/timezone
emerge --config sys-libs/timezone-data

nano -w /etc/locale.gen

en_US ISO-8859-15
en_US.UTF-8 UTF-8

env-update && source /etc/profile && export PS1="(chroot) $PS1"

Gentoo is married to Python, which is a clear mark against. Nevertheless, if we're stuck with Python, Python2 it'll be.

eselect python list
eslect python set 2

Created /etc/portage/package.use/python

PYTHON_TARGETS python2_7 -python3_4
PYTHON_SINGLE_TARGET python2_7 -python3_4

7. Configure and Install Kernel and Related Utilities

PCI utils is handy even if you already think you know what all your hardware is.

emerge --ask sys-apps/pciutils

The Lilo bootloader will be run at the `make install` step of the kernel install.

emerge -av sys-boot/lilo

Install /etc/lilo.conf within the chroot.

I'm in the habit of adding a user named build with a home directory at /var/build which I use for compiling packages by hand.

useradd -d /var/build -m -s /bin/bash build
su - build

tar xJf /usr/src/linux-4.9.tar.xz
cd linux-4.9
xz -dc /usr/src/patch-4.9.95.xz |patch -p1

I've archived the kernel configuration file I installed at /var/build/linux-4.9/.config. I used the thinkpad-static.config from Gales Linux as a basis and adjusted to the needs of this deployment. To make any changes issue :

make menuconfig

When you're all set with your kernel config,

make

(as root)
make install
cd /boot
cp vmlinuz-4.9.95 bzImage-4.9.956

8. Install some basic config files

/etc/fstab
/etc/conf.d/hostname

Set a static IP and set the network interface to the default run level.

nano /etc/conf.d/net
cd /etc/conf.d/
ln -s net.lo net.enp3s0
rc-update add net.enp3s0 default

9. Exit the Chroot and Re-enter to remove udev and install static device nodes

I learned how to do this in the Old Fashioned Install Gentoo wiki article.

Mount /proc but not /dev inside the chroot. We will be using a static /dev, so we have to emerge dev-static. With /dev bind mounted in the normal way, our static dev would go into the parents devtmpfs which is in RAM. If you are very very lucky, the static /dev provided by the stage3 may be enough to get you started.

The stage3 tarball is provided with a static /dev that includes sda ... sdd inclusive. If you need more that that, use mknod to make the extra /dev entries.

Mount the special filesystems:

mount -t proc proc /mnt/gentoo/proc

Enter the chroot:

chroot /mnt/gentoo /bin/bash

Set the chroot environment:

env-update
source /etc/profile
export PS1="(chroot) $PS1"

The Old Fashioned article says to first issue:

emerge --ask --unmerge sys-fs/udev

However, mine reported that wasn't installed, not sure. So I issued:

emerge --ask --unmerge virtual/udev

Now for static-dev, which installed makedev-3.23.1 :

emerge --ask sys-fs/static-dev

Add some groups to please MAKEDEV :

groupadd -r serial
groupadd -r kvm

Make some devices:

MAKEDEV -x tty_basic
MAKEDEV std
MAKEDEV sd{a,b,c}
MAKEDEV random
MAKEDEV snd7

And so on as needed.

Disable now spurious services :

rc-update show -V |less
rc-update delete swap boot
rc-update delete modules boot
rc-update delete udev sysinit
rc-update delete udev-trigger sysinit
rc-update delete devfs sysinit

Uninstall now spurious dependencies :

emerge --ask --depclean

The last command should offer to remove the following packages :

sys-apps/hwids
sys-fs/udev-init-scripts
sys-libs/libcap
dev-util/gperf
virtual/udev

10. Reboot

Before getting into any more changes, I like to reboot here to make sure everything I've done this far is working.

exit
cd
umount /mnt/gentoo/{proc,boot,}
reboot

Assuming you booted clean, continuamos..

11. Install X11 Window System

I went straight to emerging fluxbox, which is my preferred window manager and pulls in xorg-server and its dependencies. Consult the article on X on the Gentoo wiki as needed.

(as root)
emerge -av x11-wm/fluxbox

Which pulls in x11-base/xorg-server-1.19.38. Consult and adjust the /etc/portage/ files linked in section 4 above with the USE flags of your preference. The default media-libs/mesa had gallium enabled, which then pulls in llvm as a hard requirement. I think this is Gentoo braindamage because I consulted Jacob's recipe for building X by hand and he had gallium enabled for mesa without llvm. Anyways, I built with the gallium flag disabled, but dmesg reported the r600_dri.so file was not found. I then added modified make.conf to add r600 to the VIDEO_CARDS variable and rebuilt. According to Gentoo, mesa with gallium and thus llvm is required to support the r600 driver.

12. Configure and run X11.

I'm running X in the most straightforward way, i.e. login to a tty and issue startx to launch fluxbox. To achieve that, the following config files were installed.

echo "XSESSION=fluxbox" > /etc/env.d/90xsession
env-update

Ensure the user you plan to run startx with is in the video group in /etc/group, e.g.

video:x:27:root,dorion

In the $HOME directory of the non-root user, I added a file named .xsession with contents :

#!/bin/sh
. /etc/profile
exec startfluxbox

I'm running startx under tmux because that allows me to detach the X session and and log out of the user when I'm not around. This isn't going to stop someone who has physical access and knows what they're doing, but achieves some level of login-logout functionality. If you don't have tmux, install it now.

emerge -av app-misc/tmux

X via Gentoo is supposed to run out of the box.

tmux
startx

Startx invokes /etc/X11/xinit/xinitrc which invokes /etc/X11/xinit/xserverrc which execs /usr/bin/X. I modified xserverrc to pass the -nolisten tcp option to X.

Some potentially helpful Gentoo links :

13. Conclusion

A planned use for this machine is to play Eulora. I managed to install the v1 client and its dependencies, which will be documented in a separate article to follow.

  1. I'd prefer to use neither glibc nor dynamic linking because poettering is negrated, but I suspect musl in Gentoo is going to give me more headaches than it's worth and Gales is purely text for the time being. []
  2. I'd prefer to use Linux 2, but haven't managed that config. []
  3. Eulora requires binutils 2.26 and earlier. In my portage tree, 2.25.1 was the default, but I also have an ebuild for 2.26.1. Gales uses 2.24. []
  4. This board also comes with UEFI []
  5. Tailor to suit you. []
  6. To match my lilo.conf []
  7. Also ensure the users you want to have access to audio are in the audio group in /etc/group []
  8. This eschews x11-base/xorg-x11 which has quite a few more packages and so far I've managed without it. []

Powered by WordPress