Introduction
After using Debian for a long time, I wanted to explore other Linux distributions like Arch Linux, Gentoo, and LFS—each known for customizability and performance, albeit with a steeper learning curve. Installing these systems typically requires an existing Linux environment or a live CD.
I’ve tried all three briefly, but usually abandoned them after a few days. Gentoo’s allure lies in its high degree of control and optimization potential. What finally convinced me to switch was someone on Zhihu describing Gentoo as “a lazy person’s distro”—a statement that intrigued me enough to try it seriously.
Here’s a summary of my first week with Gentoo and the key lessons learned.
1. Kernel Compilation
Gentoo recommends starting from a stage3 tarball, which includes most essential tools—unlike LFS, where you build everything manually. The biggest challenge for me was compiling the kernel.
Although you can use a generic kernel configuration, it includes drivers for all sorts of hardware, leading to longer compile times. I chose to manually configure my kernel to include only what I needed—my GPU, sound card, network card, and file system (ext4).
With the newer 3.x kernel series, build issues are less frequent compared to the older 2.6.x versions. Kernel configuration can still be daunting for beginners, but with some research and experience, it’s manageable.
2. Driver Setup
My hardware includes a Broadcom BCM4312 Wi-Fi card and a graphics tablet. Thanks to past experience, setting them up this time was easier.
The official b43
installation guide worked before, but this time compiling the Broadcom driver directly into the kernel didn’t work. Compiling it as a module did. After ifconfig wlan0 up
, everything worked fine.
Gentoo’s network interface handling is unique. You manage interfaces by creating symbolic links in /etc/init.d
, and wireless connections are typically handled via wpa_supplicant
, which can be slow to connect and may show misleading warning messages.
3. make.conf
This is a critical file in Gentoo, where you configure compiler optimizations, USE flags, language support, and hardware drivers. It’s similar in concept to FreeBSD’s make.conf
.
Example entries include:
CFLAGS="-O2 -march=native -pipe"
MAKEOPTS="-j4"
USE="X alsa dbus gtk"
LINGUAS="zh_CN en"
VIDEO_CARDS="intel"
4. Portage and USE Flags
Gentoo’s package manager, emerge
, uses USE
flags to enable or disable optional features. Initially, I found it confusing and frequently ran into build issues.
After exploring documentation and tools like eix
and equery
, I gained confidence. The Gentoolkit and Gentoo Wiki are invaluable resources. There’s also a searchable index at gentoobrowse.randomdan.homeip.net.
Note: Some large applications like Firefox take hours to compile. For such cases, use precompiled binaries like firefox-bin
.
Final Thoughts
Installing Gentoo is an ongoing learning process. It’s a deep dive into how Linux works under the hood and forces you to understand your system intimately.
Installation Log
# Partitioning and filesystem setup
fdisk /dev/sda
mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda2
# Mount filesystems
mount /dev/sda1 /mnt/gentoo
mount /dev/sda2 /mnt/gentoo/home
...
# Download and extract stage3
wget http://mirrors.163.com/gentoo/releases/x86/autobuilds/current-stage3-i686/stage3-*.tar.bz2
wget http://mirrors.163.com/gentoo/snapshots/portage-latest.tar.bz2
tar xvjf stage3-*.tar.bz2 -C /mnt/gentoo/
tar xvjf portage-latest.tar.bz2 -C /mnt/gentoo/usr
# Prepare for chroot
cp -L /etc/resolv.conf /mnt/gentoo/etc
mount -t proc none /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash
# Configure make.conf
nano /etc/portage/make.conf
# Sync and install packages
emerge --sync
eix-sync
emerge gentoo-sources genkernel
# Build the kernel
cd /usr/src/linux
make menuconfig
make -j4 && make modules_install && make install
# Network and locale setup
ln -s /etc/init.d/net.lo /etc/init.d/net.wlan0
rc-update add net.wlan0 default
nano /etc/wpa_supplicant/wpa_supplicant.conf
# Add user and configure desktop
useradd -m -G audio,video,usb -s /bin/bash username
echo "Asia/Shanghai" > /etc/timezone
locale-gen
# Install common software
emerge -av vim emacs firefox-bin xfce4-meta wqy-zenhei guake vlc
# Setup zsh
chsh -s /bin/zsh
# Install oh-my-zsh
cd ~
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc