How to Install Gentoo: The Most Complex OS to Install

How to Install Gentoo: The Most Complex OS to Install

How to Install Gentoo Linux: Gentoo Linux Installation Guide, The Most Complex OS to Install

If Arch Linux is for those who want to build their system, Gentoo is for those who want to engineer it. In the world of Linux, Gentoo represents the pinnacle of customization—a distribution where every single binary is compiled specifically for your hardware, stripping away every ounce of bloat and leaving behind nothing but pure, raw performance.

Hey there, and welcome to MusaBase! In this guide, I'm going to walk you through the installation of Gentoo Linux, arguably the most advanced, hands-on, and rewarding Linux distribution available. If you have already mastered my Arch Linux Manual Guide, then Gentoo is your next ultimate challenge.

Unlike the declarative nature of NixOS, Gentoo gives you total control by compiling every single package specifically for your hardware. This is a UEFI-based installation guide, covering everything from the initial stage3 tarball to a fully functional system. We will tackle the critical steps that usually trip people up, including:

  • Advanced Disk Partitioning, Formatting, and Mounting
  • Configuring make.conf and USE flags (the heart of Gentoo's power)
  • Selecting and compiling the right Linux Kernel and Firmware
  • Optimizing the base system compilation process
  • Generating a rock-solid fstab and system locale settings
  • Installing and configuring the GRUB bootloader for UEFI

I've designed this guide to be technically complete yet accessible, providing all the commands, screenshots, and explanations you need. Whether you've struggled with chroot, emerge --sync, or kernel compilation in the past, don't worry, I've got you covered. Let's get started!


Here is the final result we are aiming for after finishing this Gentoo Linux installation guide:








What is Gentoo, and How does it differ from other Linux Distros?

What is Gentoo?

Gentoo Linux is a highly customizable, source-based Linux distribution known for its flexibility and performance optimization. It allows users to build their system from source code, tailoring it to their specific hardware and preferences using the Portage package management system.

  • Source-based:
    • Unlike most Linux distributions that provide pre-compiled binary packages, Gentoo compiles software from source code. This means that users can customize the compilation process to optimize for their specific hardware and desired features.
  • Portage:
    • Gentoo's package management system, Portage, allows for fine-grained control over software installation and configuration. Users can specify compile-time options for each package, ensuring optimal performance and resource usage.
  • Customization:
    • Gentoo's design philosophy emphasizes user choice and control. Users can choose which components to install, how to configure them, and how to optimize them for their specific needs.
  • Performance:
    • By compiling software from source and optimizing it for specific hardware, Gentoo can achieve high levels of performance.
  • Metadistribution:
    • Due to its highly customizable nature and source-based approach, Gentoo is often referred to as a metadistribution.

How does it differ from other Linux Distributions?

At its core, it's a serious, stable distribution that is suited to "power" users who need more flexibility than most other distributions usually offer. This flexibility means it can be many things to many people - from a stable development environment, server, embedded system, or anything any other Linux system would be used for, to a platform to learn "Linux".
The most important aspect of Gentoo is its stability. Gentoo is exceptionally stable compared to many other distributions.




Gentoo Linux Prerequisites & System Requirements

This Gentoo Linux installation guide assumes you are comfortable with core Linux concepts, including disk partitioning, networking, and kernel configuration. A reliable internet connection is required to download essential installation files and source packages. This walkthrough follows the official Gentoo Handbook. If you encounter any issues or a command doesn't work as expected, please refer back to the official documentation to verify the steps.



System Requirements:

  • Processor: Any x86_64-compatible CPU (More cores will significantly speed up compilation).
  • RAM: 512 MB minimum (4 GB+ is highly recommended for a desktop profile).
  • Disk Space: 2 GB for a minimal base, but 60 GB+ is recommended for a full environment.
  • Network: A stable broadband connection is mandatory for fetching source code.

For full details, consult the Gentoo Handbook. It provides in-depth documentation for every supported CPU Architecture and init system (OpenRC or systemd), allowing you to tailor the installation to your exact hardware.




Step 1: Boot Gentoo Live Environment (via Linux Mint ISO)

For starters, Gentoo's official minimal live ISO includes only a CLI environment and essential tools. Installing via pure CLI can be tedious. Instead, booting from a Linux Mint or Ubuntu live ISO gives us a full GUI/Desktop, Wi-Fi support, Web browsing, Simpler disk partitioning, Full Linux Toolkit plus it's user-friendly.

Why it matters:

Gentoo installs can take hours. A full GUI lets us:

  • Google errors, quickly search error messages online.
  • Open the Gentoo Handbook in your browser.
  • Copy & paste commands directly.
  • Use multiple terminal tabs or windows.

Therefore, for simplicity and avoiding any complex scenarios, booting into any Linux distro's live ISO that has a Desktop environment and a Full Linux Toolkit like Linux Mint or Ubuntu is recommended. You can download the ISO file from Linux Mint official website. After downloading the ISO, make a bootable USB stick with the ISO and reboot your PC.

1.1: Create a Bootable USB Drive

1.1.1: Using Balena Etcher (GUI) if using Windows/Mac/Linux

  • Download Balena Etcher and install it.
  • Run Etcher.
  • Select your linuxmint.iso file.
  • Choose the USB drive.
  • Click Flash! and after a few minutes, your USB will be bootable with Linux Mint ISO.

1.1.2: Using dd (CLI) if using Linux

Note: Be careful while using dd and selecting your USB drive as dd will overwrite it.

  • Plug your USB drive into your PC.
  • Open terminal and run the following command to identify your USB:
lsblk
  • Look for your USB (e.g., /dev/sdb or /dev/nvme0n1). Note the name for your USB drive.
  • Unmount the USB (if mounted) by running this command:
sudo umount /dev/sdX
Note: Replace X with your USB device (e.g., sdb1).
  • Next, write the ISO to USB by running this command:
sudo dd if=/mnt/sdc1/Downloads/linuxmint.iso of=/dev/sda bs=4M status=progress oflag=sync
Note: Replace /mnt/sdc1/Downloads/linuxmint.iso and /dev/sda with your actual path where the linuxmint.iso is located and your USB.
  • if=: Input file (ISO path).
  • of=: Output device (USB, e.g., /dev/sdb).
  • bs=4M: Block size for faster writing.
  • status=progress: Shows progress.
  • oflag=sync: Ensures data is written properly.
  • After dd finishes writing ISO to USB, eject your USB by running this command:
sudo eject /dev/sdX
⚠️ Warning: Using dd incorrectly can overwrite your hard disk. Double-check if= and of= before executing.
1.2: Boot into Linux Mint Live ISO
  • Reboot your PC.
  • While your PC is turning on, press F9, F10, F11, F12, DEL, or ESC key to open UEFI/BIOS settings.
  • Locate and disable Secure Boot & Fast Boot option (Usually it's under Security or Advanced Settings tab).
  • Save & Exit.
  • Next, again press F9, DEL or ESC key to boot from your USB stick.
  • If everything goes right, then you would be greeted by Linux Mint's GRUB menu.
  • Press Enter on Start Linux Mint 22.1 Cinnamon 64-bit.
Linux Mint GRUB boot menu showing boot options for live environment

After a few seconds, you will be inside the Linux Mint live desktop environment.

Linux Mint live desktop environment showing full GUI interface with terminal open

1.3: Switch to Root

Switching from normal user to root user is mandatory because we are going to do a lot of stuff and every single command we are going to run requires sudo.

  • Open terminal.
  • Run:
sudo su



Step 2: Partitioning & Formatting Disks for Gentoo using cfdisk

cfdisk is a text-based, curses-based utility for partitioning hard drives on Linux systems, similar to fdisk but with a more user-friendly, menu-driven interface.

2.1: Disk Partitioning

  • First, list all connected storage drives.
  • Run the following command:
lsblk
Terminal output of lsblk command showing all connected storage devices with sizes and partitions

  • Here, I have two storage drives connected to my PC. (sda, sdb)
  • I am going to install Gentoo on my second drive (sdb).

2.1.1: Run cfdisk

  • Run the following command:
cfdisk /dev/sdb
Cfdisk utility interface showing disk /dev/sdb with no partitions created yet
  • Next, select gpt label type for UEFI systems.
Cfdisk prompt asking to select partition table type, with GPT option selected for UEFI systems

Navigating cfdisk Interface

  • Use (Up ) & (Down ) arrow keys to scroll through partitions.
  • Use (Left ) & (Right ) arrow keys to access bottom menu options.
  • We can also use Tab Key TAB to cycle options (e.g., [ NEW ], [ Quit ], [ Help ], etc).
  • Type capital M for Megabytes and capital G for Gigabytes after allocating the space. (e.g., 100M, 1G, etc).
  • Press Enter ENTER to confirm.
2.1.2: Create Boot Partition
  • Select Free space selected, press TAB to select [ New ] from bottom options and press Enter.
  • Allocate 512M-1G according to your preference and press ENTER. I'm allocating my boot partition 1GB.
2.1.3: Create Swap Partition
  • Repeat the steps like we did for boot, select Free space and [ New ] then press Enter.
  • Allocate 1G-16G depending on your needs and press ENTER. I'm allocating 4G to my Swap partition.
2.1.4: Create Root Partition
  • Select Free space and press ENTER.
  • Allocate the remaining available space (already written in the prompt) and press ENTER.
2.1.5: Write Changes to Disk
  • Now that all the necessary partitions have been created, we need to write these changes to disk.
  • Press TAB and select [ Write ] and press ENTER.
  • Type yes and press ENTER.

2.1.6: Exit cfdisk Interface

  • Press TAB to select [ Quit ] and press Enter and you will be directed back to the terminal.

2.2: Formatting the Partitions

Now, we need to format each partition to their respective File System.

  • Root partition: Will be formatted in EXT4 file system.
  • Boot partition: Will be formatted in EFI file system.
  • Swap partition: Will be formatted in SWAP file system.

2.2.1: List All Storage Drives with Partitions

  • I recommend listing out all connected storage drives, so we can format each partition with convenience.
  • Run:
lsblk
Terminal output of lsblk command showing disk partitions after creation with sdb1, sdb2, sdb3
2.2.2: Formatting the Root Partition

Note: Adjust the partition name according to your drive and partition in which you are going to install Gentoo. (e.g., sdb, sda, sdc, etc).

  • Run:
mkfs.ext4 /dev/sdb3
2.2.3: Formatting the Boot Partition
  • Run:
mkfs.fat -F 32 /dev/sdb1
2.2.4: Make the Swap Area
  • Run:
mkswap /dev/sdb2



Step 3: Mount Gentoo Filesystem

Gentoo requires us to mount everything at /mnt/gentoo unlike Arch Linux where we mount everything at /mnt. So first we need to make the /gentoo directory.

3.1: Making /mnt/gentoo

  • Run the following command:
mkdir /mnt/gentoo
Terminal showing mkdir command creating /mnt/gentoo directory for Gentoo installation

3.2: Mounting the Root Partition

  • Run:
mount /dev/sdb3 /mnt/gentoo

3.3: Mounting the Boot Partition

We need to mount our boot partition at /boot/efi. But this path doesn't exist yet. So first we need to make this directory.

3.3.1: Making /boot/efi Directory

  • Run the following command:
mkdir -p /mnt/gentoo/boot/efi
Terminal showing mkdir -p command creating /mnt/gentoo/boot/efi directory structure

3.3.2: Mounting Boot Partition

  • Now we can mount boot partition by this command:
mount /dev/sdb1 /mnt/gentoo/boot/efi

3.4: Turning on the Swap Partition

  • We don't have to mount the swap partition anywhere, we only just need to turn it on with this command:
swapon /dev/sdb2



Step 4: Downloading & Extracting Stage 3 Tarball

At the moment, Gentoo provides two init systems, openrc and systemd. We can get the minimal version of Gentoo for one of these init systems or we can go with desktop profile | openrc or desktop profile | systemd.
In this guide, I'm going with minimal openrc init system.

4.1: Download the Stage 3 OpenRC Tarball

  • Go to gentoo.org/downloads.
  • Right-click on Stage 3 openrc and click on copy link.
  • Go back to terminal and run these commands consecutively:
cd /mnt/gentoo
wget "the copied link"

4.2: Extract the Tarball

  • Run this command:
tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner -C /mnt/gentoo



Step 5: Configure Compile Options & USE Flags

Now, we'll optimize compile and build options at /etc/portage/make.conf. Here we will set CFLAGS, CXXFLAGS and MAKEOPTS etc.

  • Run the following command:
nano /mnt/gentoo/etc/portage/make.conf

5.1: Setting MAKEOPTS

MAKEOPTS controls how many parallel jobs the system runs when compiling source code with make. I have an Intel Core i5-4660 processor which has 4 Cores & 4 Threads with 8GB of RAM so I am setting my parallel jobs to 5. But you can adjust this value according to your hardware resources.
The ideal formula is: -j(number of your CPU cores +1) , in my case, my CPU is 4 core, then for me it is 4 cores + 1 = 5
.

  • Add this line in the make.conf:
MAKEOPTS="-j5"
Nano editor showing MAKEOPTS='-j5' line added to make.conf file for parallel compilation
  • After adding the line, press CTRL + O to save changes, then press ENTER to confirm, then press CTRL + X to exit the file.

5.2: USE Flags

5.2.1: What are USE Flags?

USE flags in Gentoo are like feature toggles for software (packages). They let you tell Portage to "Include this feature when building this package" or "Leave that part out to save space or avoid bloat".
We can view our Global USE Flags with this command:

emerge --info | grep ^USE

By default, all flags are selected to install with the base system. But if you want to block something, let's say you want VLC Player but without its GUI and audio, then we would make the changes in the /etc/portage/make.conf like this:

USE="X -alsa"
This flag will install VLC but without its GUI and audio.

5.2.2: Where are USE Flags Defined?

There are 3 levels:

  • /etc/portage/make.conf: Global (for all packages).
  • /etc/portage/package.use/: Per-package flags.
  • Ebuilds files (defaults from Gentoo): Upstream defaults.

5.2.3: How to Change USE Flags?

  • We can edit our make.conf to set global flags:
nano /etc/portage/make.conf
  • In this file, edit or add USE="" line.
  • For package-specific flags, create a file like:
echo "media-video/vlc -qt5 pulseaudio" >> /etc/portage/package.use/vlc

5.3: Selecting Mirrors

  • Pick the fastest mirror from gentoo.org/downloads/mirrors.
  • Select your closest mirror. (e.g., CH-Switzerland or US-United States of America (USA)).
  • Go back to terminal and run nano /mnt/gentoo/etc/portage/make.conf file again and add your selected mirror URL like this:
GENTOO_MIRRORS="https://mirrors.your-selected-mirror/gentoo"
  • After adding the mirrors, press CTRL + O to save changes, then press ENTER to confirm, then press CTRL + X to exit the file.

5.4: Copying DNS Info

  • Go to Gentoo DNS Link.
  • Copy the cp command under Copy DNS info.
  • Paste the command in the terminal and press ENTER.
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/



Step 6: Mount Essential Gentoo Filesystem for chroot

This step mounts the essential virtual filesystems (proc, sys, dev) from the live environment into our new Gentoo root, ensuring all kernel interfaces and device nodes work correctly inside the chroot.

  • Again we need to go to Gentoo's Installation Handbook and copy the commands.
  • On the webpage, search for Mounting the necessary filesystems by pressing CTRL + F.
  • Next, copy each line or all at once but excluding root #.
  • I have also added the commands below, you can also copy paste from here.
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

6.1: Verify Necessary Filesystem is Mounted

  • To confirm all required filesystems are mounted, run:
mount | grep /mnt/gentoo
  • In the second image we can see that all necessary filesystems are mounted correctly.

6.2: Mount /dev/shm (Shared Memory)

  • To set up the shared memory filesystem, run these commands consecutively:
test -L /dev/shm && rm /dev/shm && mkdir /dev/shm
mount --types tmpfs --options nosuid,nodev,noexec shm /dev/shm
chmod 1777 /dev/shm /run/shm
Terminal showing commands to setup /dev/shm shared memory filesystem for chroot



Step 7: Chroot into Gentoo

With all partitions mounted and the base files in place, it's time to enter (chroot into) our new Gentoo root. This gives us a shell inside the Gentoo install, where further system configuration takes place.

7.1: Enter the Chroot

  • Run these commands consecutively:
chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) ${PS1}"

7.2: Configure Portage (Retrieve the Portage Tree)

In Gentoo, Portage is the package manager. It needs a local copy of the portage tree, which contains Ebuild scripts, Metadata, Profiles, etc. In order to get the portage tree we need webrsync.

  • Run the following command:
emerge-webrsync



Step 8: Select a Gentoo Profile

A profile in Gentoo is a predefined set of configurations that controls:

  • USE flags: Enables/disables common features globally (e.g., X, systemd, alsa).
  • Target system type: Desktop, server, hardened, minimal, etc.
  • Default packages: Some profiles pull in packages like cron, logrotate, dhcpcd, etc.
  • Toolchain settings: What compiler versions or CFLAGS are preferred.
  • Filesystem layout: Sometimes tweaks FHS (File Hierarchy Standard) compliance.
  • System behavior: Whether the system leans toward Wayland, X11, systemd, OpenRC, etc.

8.1: List Available Profiles

  • We can use eselect command for this.
  • Run:
eselect profile list
  • Here we can see list of all Gentoo supported profiles.
  • By default [21] default/linux/amd64/23.0 (stable) is selected.
  • This profile offers: a base/vanilla profile with only essential defaults for general use. lightweight, and highly customizable. Ideal for servers, power users, or building a system from scratch.
  • However, I am not choosing this profile for my system. I am choosing a profile with desktop support, though I won't be installing any graphical environment in this guide but I will cover that soon in another article.

8.2: Select a Profile

For most minimal system the pre-selected profile is well suited. But I am going to select another profile from the list.

  • Run:
eselect profile set 23
Note on Switching Profiles

When we switch Gentoo profiles, each profile brings its own set of default USE flags, these live in files under /usr/portage/profiles and get merged into our global /etc/portage/make.conf. To see exactly which USE flags are active right now, we can search make.conf for the USE line:

grep ^USE /etc/portage/make.conf
  • grep ^USE looks for any line that starts with USE (the caret ^ anchors the match to the beginning of the line).
  • It will print something like:
USE="X alsa pulseaudio dbus gtk gtk3"
  • That string shows all globally enabled and disabled flags after our profile defaults and any manual edits.
Why do we need it?
  • Verify profile defaults: Immediately after eselect profile set, run the grep command to confirm the profile's USE flags landed in make.conf.
  • Troubleshoot build issues: If a package is pulling in unexpected features (or missing support we need), checking the USE line tells us where to start.
  • Documentation & auditing: Before we compile large packages, we can capture our exact USE settings and save them alongside our installation notes.

Furthermore, profiles also drop default USE flags into /usr/portage/profiles/use.defaults (or /mnt/gentoo/usr/portage/profiles/use.defaults inside the chroot). We can inspect that directory to see a file named after each profile, which lists all the flags it enables or disables by default. For example:

cd /mnt/gentoo/usr/portage/profiles/use.defaults/amd64/23.0/desktop

If you want to install another profile which supports GNOME or KDE, use the corresponding number (e.g., eselect profile set XX (your desired profile [Index])).




Step 9: Update @world / Gentoo Full System Update

This is a critical and potentially long-running step: Portage will compile every installed package from source. On my Intel Core i5 4th-gen (4 cores, 4 Threads) with MAKEOPTS="-j5", it took nearly 12 hours. Your build time depends on CPU speed, thread count, and RAM. For slower machines, consider running the update in a screen or tmux session overnight so you can resume safely in the morning.

9.1: Resolving the @world set Error (This might happen with you too)

  • Run the below update command first and if it works then skip this step and go directly to Step 10, if any error occurs especially dev-python/pillow related then come back to this step and redo the process.
  • If we run the update command:
emerge --ask --verbose --update --deep --newuse @world
  • We may get the error shown in the second image above.
  • It is happening because:
    • Portage tried to pull in optional TrueType font-related libraries, which Pillow can use to render fonts, likely freetype, libjpeg-turbo. But one of these dependencies were either missing, were masked (unstable) or had unmet dependencies on my system.
  • This is more likely the case related to my PC only, it could be different error on your PC or this error won't happen at all.
  • Read the emerge output carefully. If it cites a USE-flag issue, disable or override that flag for the affected package.
  • These errors usually occur inside a minimal or non-desktop environment like a fresh Gentoo base system.

If at this step or any step any error occurs please let me know in the comments, I will try to resolve the issue with you as soon as possible.

How do we resolve this issue?

  • Instead of trying to install all those additional font libraries (which are unnecessary in our case), we can disable the optional truetype feature just for Pillow (the error I am having):
  • Run:
echo "dev-python/pillow -truetype" >> /etc/portage/package.use/pillow
Terminal showing command to disable truetype USE flag for dev-python/pillow package

9.2: Updating the @world set / Updating the System

  • Now, run the emerge command again:
emerge --ask --verbose --update --deep --newuse @world
  • After resolving the dependencies it will ask for confirmation, press ENTER to continue.

(Optional) Sync the Portage Tree

  • If any other error occurs (e.g., "ebuild not found", "Fetch failed", Error: media-gfx/hugin-2019.0.0::gentoo not found, etc), then sync the Portage Tree again with:
emerge-webrsync
# or
emerge --sync



Step 10: Install a Prebuilt Kernel & Firmware Packages

To save time, we'll use a prebuilt kernel package. However, if we go for source-based kernel, that will give us maximum control over what's included in our kernel. We can strip out unneeded drivers, optimize for our specific CPU architecture, and include bleeding-edge features. But compiling a source-based kernel will consume a significant amount of time and power usage.

10.1: Install the installkernel Helper

  • Since we chose the OpenRC init system, install Gentoo's installkernel tool (it respects your init choice).
  • Run the emerge command:
emerge --ask sys-kernel/installkernel

10.2: Enable dracut for installkernel

Dracut is a software tool used to create an initial RAM filesystem (initramfs) for Linux systems. It's a modular system that helps automate the early boot process by providing necessary drivers and configurations to access the root filesystem. Essentially, dracut creates a temporary filesystem that the kernel uses before loading the main operating system.

  • Now to install our pre-compiled kernel we need to add Dracut USE flag for installkernel at /etc/portage/package.use/installkernel.
  • It's really simple, we just need to run the echo command.
  • Run:
echo "sys-kernel/installkernel dracut" >> /etc/portage/package.use/installkernel

10.3: Installing the Gentoo's Pre-Compiled (Binary) Kernel

  • Now that everything is set, let's install the binary kernel.
  • Run:
emerge sys-kernel/gentoo-kernel-bin

10.4: Install Linux Firmware

10.4.1: Accept-License

Gentoo gives us fine-grained control over what software licenses we are willing to accept for packages we install, for legal, ethical, or organizational reasons.
By default, Gentoo allows only free/open-source licenses (like GPL, MIT, BSD). If a package uses a restrictive or proprietary license (like Oracle's license for virtualbox or the Adobe EULA), Portage will block the installation unless we explicitly accept that license.

  • For this guide, I am accepting all kinds of licenses (non-free or EULA-bound) included.
  • Follow these steps:
nano /etc/portage/make.conf
  • Add the following line:
ACCEPT_LICENSE="*"
  • Add the line like shown in the second image below.
  • Now, press CTRL + O to save the changes, then press ENTER to apply the changes, then press CTRL + X to exit the file.

10.4.2: Install Linux Firmware Blobs

Installing Linux Firmware in Gentoo is essential because many hardware components require binary firmware blobs to function properly. These firmware files are not built into the kernel and must be installed separately.
It is mostly needed for:

  • Wi-Fi cards.
  • GPUs.
  • Sound cards.
  • Bluetooth adapters.

Kernel loads firmware at boot. During system startup, the kernel may try to load firmware from /lib/firmware. If it's missing, the kernel logs errors and that hardware might not function.

  • To install Linux firmware, run:
emerge --ask sys-kernel/linux-firmware



Step 11: Configure Base-system

Now everything needed to run an actual Gentoo system has been installed, the only bits left are setting up our base system, such as locale, timezone, root password, bootloader, etc.


11.1: Configuring Timezone
  • You can set timezone according to your region.
  • We can run the echo command to set the timezone and cat command to verify that our timezone is set correctly.
  • Run these commands consecutively:
echo "Asia/Karachi" > /etc/timezone
cat /etc/timezone
  • Now, we need to apply it by reconfiguring the timezone-data package.
  • Run:
emerge --config sys-lib/timezone-data
11.2: Generating Locale

Generating locale means creating the necessary language and regional settings (like date format, currency, character encoding) that our system will use for displaying text and formatting information. It's really simple, just follow these steps:

  • Run:
nano /etc/locale.gen
  • Navigate down with your keyboard's down () arrow to select your preferred locale.
  • Press BACKSPACE or DEL key to remove the leading # from the start of the line (e.g., en_US.UTF-8 UTF-8).
  • Press CTRL + O to save the changes, then press ENTER to apply the changes, then press CTRL + X to exit the file.
  • I am choosing en_US.UTF-8 UTF-8, but you can either select from already given in locale.gen file or if your preferred locale isn't listed, then just simply add your locale and save the file.
  • Now, to generate the selected locales, run:
locale-gen
Terminal showing locale-gen command execution to generate system locales
  • Now, we need to update the locale for the system's environment in a more centralized "Gentoo" way.
  • Run:
eselect locale list
  • It will list out locales with their index.
  • To set your locale, run:
eselect locale set 4
11.3: Generate fstab

The fstab defines how file systems are mounted at boot. It contains a table of information about devices, mount points, file system types, and mount options. This file is crucial for automatic mounting of file systems, including local and remote ones, and ensures proper system startup and functionality.
However, in Gentoo we need to generate the fstab manually unlike we do on Arch Linux. But we can use Arch Linux fstab method here as well. Since we are in Linux Mint Live ISO and we have access to a complete Desktop environment with a full Linux toolkit system, we can install Arch utilities even in Mint, and it saves us from writing /etc/fstab manually.

11.3.1: Install arch-install-scripts

  • Open a new terminal inside your live ISO.
  • Next, run these commands consecutively:
sudo su
apt install arch-install-scripts

11.3.2: Generating fstab

  • First, let's preview the output of our fstab.
  • Run:
genfstab -U /mnt/gentoo

11.3.3: Save fstab to a File

  • Next, we need to save this information in a file inside our /mnt/gentoo/etc/fstab, so Gentoo can use this file at boot to mount our partitions.
  • Run:
genfstab -U /mnt/gentoo | tee /mnt/gentoo/etc/fstab
  • Now to verify that our fstab is saved in /etc/fstab correctly, switch back to Gentoo terminal.
  • Run:
nano /etc/fstab
  • Here we can see the fstab entries are stored correctly with correct partition and UUIDs.
  • Press CTRL + X to exit the file.
11.4: Hostname & Hosts File

11.4.1: Edit Hostname

  • To set hostname, we simply need to edit /etc/conf.d/hostname.
  • Run:
nano /etc/conf.d/hostname

11.4.2: Edit Hosts File

  • To edit Hosts file, we just need to repeat the step like we did for Hostname. Open the /etc/hosts and add our host entry.
  • Run:
nano /etc/hosts
  • In this file, under # IPv4 and IPv6 localhost aliases, add your host like this:
127.0.0.1     MusaBase
11.5: Root Password
  • To set the root password, simply run:
passwd
  • Enter then re-enter your password, and your root password will be set.
11.6: Installing Essential Utilities
  • Next, I am going to install some additional packages that will help us inside our installed Gentoo system.
  • Run the emerge command with package names like this:
emerge dhcpcd sudo screenfetch grub efibootmgr
Package Breakdown:

11.6.1: Installing iwd for WiFi/Wireless Connectivity

  • To connect to WiFi in the installed system, we need the iwd package.
  • Run these commands consecutively:
emerge --ask net-wireless/iwd
rc-update add iwd default
  • The second command will enable iwd service so that it will start automatically on boot.
11.7: Configure Bootloader (GRUB)
  • First, we need to run the grub-install command and then generate the GRUB configuration.
  • We can install GRUB by any of these methods:
grub-install /dev/sdb
  • Or we can use the modern UEFI approach like this:
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
  • Now, we need to generate the GRUB configuration file.
  • Run:
grub-mkconfig -o /boot/grub/grub.cfg
11.8: Adding a User & Granting SUDO Privileges

11.8.1: Adding a User

  • We can add a user with this command:
useradd -m -G wheel,users -s /bin/bash musabase
Terminal screenshot showing the 'useradd -m -G wheel,users -s /bin/bash musabase' command adding a new user to the system.

11.8.2: Setting User's Password

  • Run:
passwd musabase
  • Replace musabase with your username.
  • Enter and re-enter your password for your user, and your user password is now set.
Terminal screenshot showing the 'passwd musabase' command being used to set a password for the new user.

11.8.3: Granting User SUDO Privileges

  • Remember we installed the sudo package with some other additional packages in the previous step.
  • This package contains files for root or sudo privileges.
  • We are going to edit the visudo file for the wheel group to which we added our user.
  • Run:
EDITOR=nano visudo
  • Scroll down to the bottom with your keyboard's down () arrow key.
  • Look for a line that contains:
# %wheel ALL=(ALL:ALL) ALL
  • Delete the # from the start of the line by pressing the DEL or BACKSPACE key.
  • Press CTRL + O to save changes, then press ENTER to apply the changes, then press CTRL + X to exit the file.
11.9: Finalizing & Rebooting

11.9.1: Cleaning Stage Archive

  • Before finally rebooting, we need to clean one file: the Stage 3 archive we downloaded in Step 4.1. Without removing this file, we may encounter serious issues.
  • First, we need to change our directory, then use the rm -rf command.
  • Follow these steps:
cd /
ls
rm -rf stage3-amd64-openrc-xxxxxxxxxx.tar.xz
Terminal screenshot showing the commands 'cd /', 'ls', and 'rm -rf stage3-amd64-openrc-xxxxxxxxxx.tar.xz' being executed to remove the Stage 3 tarball.

11.9.2: Reboot

  • To finally reboot, we need to exit from Gentoo's chroot and Linux Mint's root environment and unmount all drives.
  • Follow these steps:
exit
exit
sudo umount -a
reboot



Step 12: Boot into Gentoo System

  • The very first screen we will see is our bootloader (GRUB).
  • Press ENTER on *Gentoo GNU/Linux.
Screenshot of the GRUB boot menu showing the 'Gentoo GNU/Linux' entry as the selected option, ready to boot.
  • After a few seconds, we will be greeted by Gentoo's login prompt.
  • Enter your username & password.
  • Now, if we run the screenfetch command, we can view information about our system.
Terminal output of the 'screenfetch' command running in Gentoo, displaying the Gentoo logo, system information, kernel version, and shell details.


πŸ† Congratulations! You have survived the Gentoo installation!

With a bare-bones Gentoo system now installed, you have officially dived deeper into the Linux kernel and system internals than most users ever will. This minimal foundation is now ready to be transformed into a powerful, optimized workstation tailored specifically to your hardware.

What's Next?

🎨 Complete Your Desktop: Now that the base is ready, follow my follow-up guide on installing XFCE on Gentoo to set up a fast, stable, and ultra-lightweight desktop experience.

πŸ–₯️ Risk-Free Learning: If you want to experiment with advanced Portage configurations or custom kernels without breaking your host, check out my QEMU/KVM setup guide for near-native virtualization.

πŸ“– Master the Tools: For quick reference, keep the Gentoo Cheat Sheet handy, or visit the Official Documentation for advanced DIY system tuning.

πŸ› ️ Support & Feedback: Gentoo is a journey. If you hit any snags with emerge, USE flags, or kernel panics, drop a comment below and I'll help you troubleshoot.

If this manual walkthrough helped you conquer Gentoo, subscribe to our newsletter for more elite-level Linux tutorials.
101 out, I’ll see you in the next one! πŸš€

Load comments