Now we will get all the necessary files to build a virtual environment to compile the kernel
- Start by setting up the time, assuming we got network access
chronyd -q
# display time
date
We move to the (future) root directory and choose a stage tarball. I went with Stage 3 OpenRC
cd /mnt/gentoo
# terminal browser, go to downloads
links https://www.gentoo.org/downloads/mirrors
# file: stage3-amd64-systemd-20230521T160357Z.tar.xz
# unpack while preserving namespaces and ownerships
tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner
Mirrors and filesystem
You can save some time and skip this section by running the
script curl http://files.aghriss.net/gentoo/mirror_fs.sh | bash
-
Open
/mnt/gentoo/etc/portage/make.conf
and add-march=native
toCOMMON_FLAGS
. -
Select mirrors of the distribution
mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf
- Create the ebuild repository config
mkdir --parents /mnt/gentoo/etc/portage/repos.conf
cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf
- Copy DNS settings
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/
- Mount the filesystem
mount --types proc /proc /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
mount --make-rslave /mnt/gentoo/dev
mount --bind /run /mnt/gentoo/run
mount --make-slave /mnt/gentoo/run
Chrooting
- Change the root directory to /mnt/gentoo:
chroot /mnt/gentoo /bin/bash
source /etc/profile
# add chroot to terminal to distinguish non-chroot
export PS1="(chroot) ${PS1}"
- Mount the boot partition. You can run
mount -l
afterward to list all mounts
mount /dev/nvme0n1p1 /boot
Portage
- Set network protocol and refresh the ebuild repo (one is enough)
# if you need to bypass http/https/ftp firewall rules
emerge-webrsync
# update ebuild repository
emerge --sync
Gentoo has a news medium to push critical messages use eselect news
to manage it (list
, then read 1 | less
). After
running the previous command you might get "? news items need reading". I'm already loving this 'Distro'. It feel like
Agent 47 getting some secret intel.
It's time then to choose a mission. The profile
is the foundation of Gentoo, which sets the initial USE and *
CFLAGS*. These control the packages to install and their settings.
- Select a profile using
eselect profile list
. I'll go for the default plasma
# default/linux/...desktop/plasma
eselect profile set 9
# update flags
emerge --ask --verbose --update --deep --newuse @world
The last step has taken ~ 4 hours, I'm not sure if I know what I'm doing. The root partition seems to be taking ~ 5GB, which is reasonable. The subsequent steps are similar to Arch.
# list timezones : ls /usr/share/zoneinfo
echo "Europe/Paris" > /etc/timezone
merge --config sys-libs/timezone-data
# configure locale
nano -w /etc/locale.gen
This is where Gentoo begins.
- You can see your default profile using
eselect profile show
. It's a symlink to your choice from the profiles database located at/var/db/repos/gentoo/profiles/
and its files (plasma) at subfoldertargets/desktop/plasma
. These are not to be edited. Instead, use/etc/portage/make.conf
to append/remove flags. - Use
portageq envvar USE
to see the current list of use flags
I've encountered a circular dependency link while trying to install vim emerge --ask app-editors/vim
. The dependency
cycle: libsndfile > libmpg123 > pulseaudio > libsndfile
. The trick is to temporarily recompile a minimal libsndfile
by doing:
# temporarily edit USE
USE=minimal emerge -1 media-libs/libsndfile
then install vim, which would also restore previous config dependencies.
Again, I'm rethinking my choice of distro. I've randomly stumbled upon the following comment on reddit while searching for some details about Gentoo. It seemed like a sign for me to continue down this road:
"[...] even after a long time, you will never quite stop tearing your hairs out and pleading to the elders of Portage to resolve your slot conflicts during an update. But you will persevere, as each problem will reveal more of the system and the power you gain from it is unmatched by any other. Soon you'll realize that all this complexity behind Gentoo, the all-tangled mess of dependencies, conflicting versions and configurations, this is what modern software is and that it's simply been hidden away from you.
And with your skills forged by the flames, once you return to beginner pastures, you will find yourself confused by their simplicity. You will seek to dive into the guts of their tools and find all possible knobs and dials to adjust, simply because you are now able to guess how the system works from first sight alone, and you want to make sure that it works as predictably as you anticipate. And realizing how little control over your environment you have now, you may seek to return to the darkness once more.
and so shall we attempt... In Sha'Allah