Gentoo with runit (part1)
I have been using Gentoo Linux for the last 13 years but I do like to try other distros whether on virtual machines or on bare metal, and whenever a distro has something interesting to offer, the thought that always comes to my mind is: "I can do this on gentoo but better".
...
Void Linux is one of those distros. Its biggest selling point is the fact that it uses runit as its init system and service supervisor, and runit is such a fantastic tool, it's fast, simple, and easy to use.
So I decided to try it on Gentoo. I would first try it on a virtual machine, and if it succeeded, I would move it to bare metal. I do my Gentoo installs using a live environment so I have access to a terminal, a file manager, and a web browser, and because I was going to type lots of commands and use some of my config files, it's handy to have a shared clipboard between virtual machine and host.
With that done, I started by creating the filesystems (went with ext4), downloading and extracting the Gentoo Linux stage 3 (I went with the stage3-amd64-openrc), and chrooting into it.
Once inside, I would have to edit some system files. I wanted to keep it minimal and able to use it on different machines, or maybe even share it.
So the first and most important file to edit is /etc/portage/make.conf, and yes, I do use some funky compiling flags on it, but I never had any issue with it. I did need to change the CFLAGS from -march=native to something more generic like -march=x86-64-v3, yes v3, it's 2026 now.
DEVIRTLTO="-fdevirtualize-at-ltrans"
GRAPHITE="-fgraphite-identity -floop-nest-optimize"
IPAPTA="-fipa-pta"
LTO="-flto -fuse-linker-plugin -fno-fat-lto-objects"
SEMINTERPOS="-fno-semantic-interposition"
COMMON_FLAGS="-march=x86-64-v3 -mtune=generic -O3 -pipe -fomit-frame-pointer -ftree-vectorize ${GRAPHITE} ${DEVIRTLTO} ${IPAPTA} ${LTO} ${SEMINTERPOS}"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
LDFLAGS="-fuse-ld=mold -Wl,-O1 -Wl,--as-needed -Wl,--sort-common"
CPU_FLAGS_X86="avx avx2 bmi1 bmi2 f16c fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
RUSTFLAGS="-C opt-level=3 -C target-cpu=x86-64-v3"
MAKEOPTS="-j8 -l8"
ACCEPT_KEYWORDS="amd64"
FEATURES="candy clean-logs parallel-fetch parallel-install"
EMERGE_DEFAULT_OPTS="--ask --autounmask-write=y --keep-going=y --with-bdeps=y"
ACCEPT_LICENSE="*"
PORTAGE_NICENESS=19
AUTOCLEAN="yes"
LINGUAS="en en_GB pt pt_PT"
L10N="en en-GB pt pt-PT"
INPUT_DEVICES=""
SANE_BACKENDS=""
VIDEO_CARDS=""
USE_ENABLED="acpi branding cryptsetup dbus jit lm-sensors lto pgo policykit polly runit udisks unwind zram"
USE_DISABLED="-bindist -doc -flatpak -gnome -gtk2 -handbook -kde -man -openrc -qt4 -qt5 -systemd"
CODECS=""
MEDIA="alsa bluetooth dri dts encode egl gles2 jack jpeg mtp pipewire png pulseaudio rar svg usb xml xv zip zstd"
USE="${USE_ENABLED} ${USE_DISABLED} ${CODECS} ${MEDIA}"
PORTDIR="/var/db/repos/gentoo"
DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"
LC_MESSAGES=C
Next, /etc/portage/package.use/base
#gcc
sys-devel/gcc cet graphite jit lto nptl pgo rust vtv
#intel
sys-firmware/intel-microcode initramfs
#kernel
dev-util/perf libpfm
sys-kernel/installkernel systemd systemd-boot ugrd
sys-kernel/gentoo-kernel experimental
sys-libs/binutils-libs 64-bit-bfd
virtual/linux-sources firmware
#misc
app-text/xmlto text
#runit
sys-process/runit scripts system-init
#rust
dev-lang/rust-bin clippy profiler rls rustfmt
virtual/rust profiler rustfmt
#sudo
app-admin/sudo offensive
#systemd-utils
sys-apps/systemd-utils boot kernel-install sysusers
#zlib
sys-libs/zlib minizip
A little explanation here: eudev, used by Void Linux, is unsupported by Gentoo Linux, and looking at its GitHub, it looks abandoned. Gentoo Linux's stage 3 comes with systemd-utils preinstalled, and at this point it would be a lot of hard work to avoid it. Also, my goal was to replace OpenRC with runit as the system init and service supervisor, not to get rid of systemd code, so I might as well make use of it. Also, I like systemd-boot.
Next, I needed to unmask some packages on /etc/portage/package.accept_keywords/base
#kernel
=sys-kernel/gentoo-kernel-7.1.5 ~amd64
=virtual/dist-kernel-7.1.5 ~amd64
#modprobed-db
sys-kernel/modprobed-db ~amd64
#runit
sys-process/runit ~amd64
~ # emerge -auDN @world
I had 108 packages to emerge.
(I did have to compile sys-devel/gcc and sys-devel/mold without -fuse-ld=mold and ${GRAPHITE} ${DEVIRTLTO} ${IPAPTA} ${LTO} ${SEMINTERPOS} before emerging @world, otherwise it would fail.)
Now it was finally time to install runit:
~ # emerge sys-process/runit
...Part2
Comments
Post a Comment