Gentoo: the system I cut to fit
Why I run Gentoo: packages from source, USE flags as the cut, a patch as a file — and what it costs in everyday life.
I do not want to carry anything on a system that I do not need. Gentoo builds every package from source and lets me decide beforehand which parts go in at all. That is why it runs here, and why it does not run everywhere.
What Gentoo does differently
With a ready-made distribution I get a package the way its packager built it: with a graphical interface, printer support, sound, tests and documentation. With Gentoo I decide that before the build. Three things do the work:
- Portage is the package manager. It resolves dependencies, builds in the right order and installs nothing that was not asked for.
- USE flags are switches for optional features.
Xpulls in the X11 libraries,gtkthe interface library,cupsthe printing service. Whoever switches them off does not get them — and does not have to maintain their dependencies either. - A profile sets the foundation: architecture, C library, init system, hardening. I use the hardened 64-bit variant with systemd.
The sources are on my disk when I need them, and I may change them. I do not have to write any of it myself.
Cutting to fit: the switches
The cut lives in /etc/portage/make.conf. In spirit, shortened:
COMMON_FLAGS="-O2 -pipe -march=x86-64-v2"
MAKEOPTS="-j<N>"
USE="-X -gtk -kde -gnome -cups -bluetooth -wifi -doc -examples -test"
FEATURES="buildpkg"
What is switched off is not compiled in, in the packages that know the flag: none of the big desktop environments, no printer, no Bluetooth, no Wi-Fi management, no documentation, no test runs. On a machine that provides services I do not need any of that. With the flag the dependencies go too that it would otherwise have pulled in. That is no substitute for checking what is installed — dependencies of other packages can pull the same library in anyway.
MAKEOPTS determines how many build processes run at the same time. A rule of thumb
is the number of cores plus one; with little memory it is memory that limits the build,
not the core count, and then only a smaller value helps.
-march=x86-64-v2 is the architecture the compiler optimises for. If you only
ever supply this one machine, you take -march=native and get the full
instruction set of the installed CPU. I stay with x86-64-v2 because the finished
packages then also run on other machines without being rebuilt. Both are
defensible; you should know which of the two you picked.
Patches: one file in one directory
With Gentoo a patch is a file in a directory. If I want a change to a package, I put it there:
mkdir -p /etc/portage/patches/app-misc/example
cp my-fix.patch /etc/portage/patches/app-misc/example/
emerge -1 app-misc/example
The patch is applied on the next build. Undoing it means: remove the file, rebuild the package. No fork, no own repository, no package maintainer who has to agree. The price: the patch has to match the source, otherwise the build fails — and on the next version bump it may fail again. That shows up in the log, not in someone else’s bug tracker.
If you only want to change a single line, you write a small patch for it — same directory, same effect. Gentoo calls them “user patches” and applies them in alphabetical order.
Binary packages: build, but not twice
FEATURES="buildpkg" stores every built package additionally as a binary
package. Whoever has two machines with the same profile builds once and installs
on the second. After a failed attempt the way back is shorter too: the old
package is still there.
What gets rebuilt is what changed: a new version, a different USE flag, a new
dependency. With buildpkg the finished package comes from the local store; Gentoo
also runs an
official binary package host
that can supply machines without building themselves.
The kernel: I take the ready-made one
I do not build my own kernel. This machine runs the prebuilt kernel package from the tree, updated through Portage like any other package. If you have unusual hardware or want to fine-tune kernel options, build your own; for my case the ready-made kernel is the better choice.
When a build fails
Sometimes things fail. Not daily, but they do: a patch no longer applies, a library has changed its interface, a package expects a flag I switched off. Then the terminal shows a line with the path to the log, and the log shows the compiler error.
My order in that case: read the log, find the cause, make the smallest change,
continue the build instead of starting over. I also have --keep-going in my
defaults: one error then does not stop everything else, it is collected and
reported at the end. Convenient, but the risk of overlooking an error grows. If you
use it, you really have to read the summary at the end.
What “hardened” means here
The profile is called hardened; the hardening sits in the toolchain. Programs are
built position-independent (pie) and with stack protection against overflows
(ssp) by default — you have to switch that off explicitly, with USE="-pie" or
USE="-ssp". On my machine seccomp comes on top, which lets programs filter
their system calls.
That costs computing time during the build; some packages take longer than with the standard profile. The protection applies at run time, the build time falls once.
What it costs
Time. A small package builds in seconds, a medium one in under a minute — that is not the problem. The effort lies elsewhere:
- A complete rebuild of the system, every dependency from source, is an evening or two, not an afternoon.
- With every larger update come notes about USE flag changes, masks and profile migrations. You read them, or you get annoyed.
- On first setup it is not an installer you click through three times, but a handbook you read.
Whoever lacks the time often notices only when an update does not go through.
When I advise against it
Gentoo is not a system you run on the side.
- On a laptop someone needs for work: a failed build in the evening is a problem in the morning.
- On a fleet of servers: updating ten machines one by one is manual work. Whoever needs that takes a distribution with planned, unattended security updates.
- Without time to read: see above.
If two of these apply, Gentoo is the wrong choice.
How I set it up
The path is well documented, so here only the order, not every command:
- Read the handbook — from the live environment to the first boot. It is complete and current, which is not a given for instructions on the web.
- Set the profile and write
make.conf: USE flags,MAKEOPTS, architecture. That is the cut; you can change it later, but then it rebuilds. - Build
@worldand then run--depclean. What is no longer needed disappears. - Update with
emerge -avuDN @world— read what is announced, then build.
For most packages I know why they are installed. Whoever cannot spend the time for that takes a ready-made system.
Sources
All addresses retrieved on 25 November 2026, each answered HTTP 200.
- Gentoo Linux, project page: https://www.gentoo.org/
- Gentoo handbook: https://wiki.gentoo.org/wiki/Handbook:Main_Page
- Portage and USE flags: https://wiki.gentoo.org/wiki/USE_flag
- Applying your own patches: https://wiki.gentoo.org/wiki//etc/portage/patches
- Compiler options and
-march: https://wiki.gentoo.org/wiki/GCC_optimization - Binary packages: https://wiki.gentoo.org/wiki/Binary_package_guide
- Distribution kernel packages: https://wiki.gentoo.org/wiki/Project:Distribution_Kernel
- Toolchain hardening (
pie,ssp), Hardened FAQ: https://wiki.gentoo.org/wiki/Hardened/FAQ - Official binary package host, Gentoo Binary Host Quickstart: https://wiki.gentoo.org/wiki/Gentoo_Binary_Host_Quickstart