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 dynamic(i) |
Kernel | Linux 4.9(ii) |
Coreutils | binutils 2.25.1(iii) |
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 mode(iv), 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. (cached)
CFLAGS="-march=bdver2 O2 -pipe"
March 2023 update : -march
isn't a requirement, I've run with the below just fine on different hardware :
CFLAGS="-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/devchroot /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.0echo "UTC" > /etc/timezone
emerge --config sys-libs/timezone-datanano -w /etc/locale.gen
en_US ISO-8859-1(v)
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.95(vi)
8. Install some basic config files
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. (cached)
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 snd(vii)
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.3.(viii) 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 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.
- 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. [^]
- I'd prefer to use Linux 2, but haven't managed that config. [^]
- 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. [^]
- This board also comes with UEFI [^]
- Tailor to suit you. [^]
- To match my lilo.conf [^]
- Also ensure the users you want to have access to audio are in the audio group in /etc/group [^]
- This eschews x11-base/xorg-x11 which has quite a few more packages and so far I've managed without it. [^]
Updated to include a more generic version of the CFLAGS parameters.
Also I added links to cached versions of the Gentoo wiki because fuck them sideways with a spiked stick they can't be relied on.
From their current version.
Meanwhile :
Win.
Granted, I've never "upgraded" since 2017, so if you're going with a recent .iso and stage3 from them you might run into some difficulties which I'm not likely to bang my head against the wall to help you sort out. Though if you ask nicely, I'll consider making my 2017 versions available for download.
Comment by Robinson Dorion — March 24, 2023 @ 17:21
I found this article via ossasepia, a really helpful writeup. I used this to refresh my memory on client build (inside a chroot) and it worked flawlessly.
I have a stage3 tarball preserved (20170209.tar.bz2) on my www also if that helps any folks wishing to tackle a Gentoo build.
Comment by shinohai — June 5, 2023 @ 17:21
@shinohai, cheers !
Comment by Robinson Dorion — June 7, 2023 @ 16:54