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-system-the-most-complex-os-to-install-cover-photo

Hey there, and welcome to MusaBase! In this guide, I’m going to walk you through how to install Gentoo Linux, arguably one of the most advanced and hands-on Linux distributions out there. If you’ve ever wanted to build your system from the ground up and understand every piece that goes into it, Gentoo is the way to go.

This is a UEFI-based installation guide, and I’ll cover everything from the initial stage3 tarball all the way to booting into your own Gentoo system. Along the way, we’ll tackle the steps that usually trip people up, like:

  • Disk Partitioning, Formatting and Mounting
  • Configuring make.conf and USE flags (the heart of Gentoo customization)
  • Picking the right Linux Kernel and Firmware
  • Compiling the base Gentoo system
  • Generating fstab
  • Configuring essential system settings (locale, timezone, users, sudo)
  • And finally, installing and setting up GRUB bootloader.

I’ve written this guide to be beginner-friendly but technically complete with all the commands, screenshots, and explanations you’ll need. So if you've ever been stuck at chroot, emerge --sync, or grub-install, don’t worry, I’ve got you covered. Let’s get started!


We would have this on our screen once we finish this Gentoo Linux installation guide:

gentoo-screenfetch







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 user 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 distrobutions that provide pre-complied binary packages, Gentoo compiles software from source code. This means that users can customize the compilation process to optimize for their specific hardwareand 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. User 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 optimzing it for the 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 metadistribution.

How does it differ from other Linux Distributions?

At it's core a serious, stable distribution, that is suited to "power" users that 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, or anything any other Linux system would be used for, through a platform to lean "Linux".
The most important aspect of Gentoo is it's stability. Gentoo is exceptionally stable. Compared to many other distributions.




Gentoo Linux Prerequisites & System Requirements

Gentoo Linux installation guide assumes your're comfortable with core Linux concepts: partitioning, networking, and kernel configuration. A reliable Internet connection is required to download installation files and packages. This walkthrough follows the Gentoo Official Handbook: Installation Guide. If you encounter any issue or a command doesn't work as shown, please refer back to that guide to verify the steps.



System Requirement:
  • Processor : Any x86_64-compatiable CPU.
  • Ram: Varies between 512 MB minimum (4 GB+ recommended for desktop).
  • Disk Space: 2 GB-60 GB+ (varies by profile and packages).
  • Network: Stable broadband connection.

For full details, see the Gentoo Handbook. It provides in-depth decoumentation for every supported CPU Architecture and init system, so you can tailor your install to your hardware and preferences.




Step 1: Boot Gentoo Live Environnment (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 its user-friendly.

Why it matters:

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

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

Therefore for simplicity and avoiding any complex scenario, 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 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 and install it.
  • Run Etcher.
  • Select your linuxmint.iso file.
  • Choos the USB drive.
  • Click Flash! and after a few minutes your USB will be booted 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 the /mnt/sdc1/Downloads/linuxmint.iso and /dev/sda with your actual path where the linuxmint.iso is located and to 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 disl. 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 its 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-menu

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

linux-mint-live-desktop-env

1.3: Switch to Root

Switching from normal user to root user is mandatory becuase we are going to do a lot of stuffs 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
run-lsblk-to-list-out-all-connected-storage-device

  • 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
run-cfdisk-dev-sdb-command-to-partition-sdb-drive
  • Next, select gpt label type for UEFI systems.
select-gpt-for-label-for-uefi-system

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 by 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 has 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.5: 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
listing-out-all-connected-storage-drives-with-partitions
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 / Partitions at /mnt/gentoo

Gentoo requires us to mount everything at /mnt/gentoo unlinke 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
making-mnt-gentoo-directory-to-mount

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 directoy.

3.3.1: Making /boot/efi Directory

  • Run the following command:
mkdir -p /mnt/gentoo/boot/efi
making-boot-efi-directory-to-mount-boot-partition

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 (OpenRC)

Go to gentoo.org/downloads/ to select a Stage 3 tarball. At the moment Gentoo provides two init system, openrc and systemd we can get the minimal version of Gentoo for one of these init system 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 Gentoo 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

< h3>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"
adding-makeopts-line-in-make-conf-file-for-gentoo-to-compile
  • 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 (pacakges). They let you tell Portage that "Include this feature when building this package" or "Leave that part out to save space or avoid bloat".
We can view out Global USE Flags by 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, lets 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 the 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/user/: 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 the 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 fielsystems (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 filesystem are mounted correctly.

6.2: Mount /dev/shm (Shared Memory)

  • To set up the shared memory fileystem, 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
mounting-symlink



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) compilance.
  • 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 customizeable. 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 envrionment 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 carret ^ 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 falgs 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 issue: 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 installtion notes.

Furthermore, profiles also drop default USE flags into /usr/portage/profiles/use.defaults (or /mnt/gentoo/usr/protage/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.default/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, conside 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 esepcially dev-python/pillow related then comback 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 pacakge.
  • This errors usually occurs, 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 fetaure just for Pillow (the error i am having):
  • Run:
echo "dev-python/pillow -truetype" >> /etc/portage/package.use/pillow
disabling-truetype-flags-for-python-pillow

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 Protage 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 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 driversand 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, lets 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 install unless we explicitly accepted that license.

  • For this guide, i am accepting all kind of license (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 becuase 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 need 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 acutal 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 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 () 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
locale-gen-to-generate-locale
  • 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 locale and remote ones, andensures 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 insatll Arch utilities even in Mint, and it saves us from writing /etc/fstab manually.

11.3.1: Install arch-install-scripts

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

11.3.2: Generating fstab

  • First, lets 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 on 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 just 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.
  • 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 root password just simply run:
passwd
  • Enter then re-enter your password and your root password is 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 packages 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 installed system we need iwd package.
  • Run these commands consecutively:
emerge --ask net-wireless/iwd
rc-update add iwd default
  • The second command will enable iwd services so that it will start automatically on boot.
11.7: Configure Bootloader (GRUB)
  • First we need to run the grub-install and then we need to generate the GRUB config.
  • We can install GRUB by any of these methods:
grub-install /dev/sdb
  • Or we can use the most modern approach like this:
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
  • Now, we need to generate GRUB config.
  • 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 user with this command:
useradd -m -G wheel,users -s /bin/bash musabase
adding-user-with-useradd-command

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.
setting-user-password

11.8.3: Granting User SUDO Privileges

  • Remember we installed 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 VISUDO file for Wheel group to which we added our user.
  • Run:
EDITOR=nano visudo
  • Scroll down to 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 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 do clean one file, the Stage 3 file which we downloaded in the Step 4.1, without removing this file we will have some serious issues.
  • First we need to change our directory then use rm -rf command.
  • Follow these steps:
cd /
ls
rm -rf stage3-amd64-openrc-xxxxxxxxxx.tar.xz
cleaning-stage3-file

11.9.2: Reboot

  • Now to finally reboot, we just 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 fist screen we will see is our bootloader (GRUB).
  • Press ENTER on *Gentoo GNU/Linux.
grub-menu-with-gentoo
  • After a few seconds we will be greeted by Gentoo's login prompt.
  • Enter your username & password.
  • Now, if we run screenfetch command, we can view info about our system.
gentoo-screenfetch



Afterwards

With bare-bones Gentoo system installed, you're free to dive deeper into how Linux works under the hood. I'll publish a follow-up guide on adding a full Desktop environment, like KDE or a Wayland compositor like Hyprland, plus advanced tutorials on Portage configuration and syste optimization. For quick reference, see the Gentoo cheat sheet and for more information about its environment or visit Gentoo Documentation Page to do DIY stuff, this way you can have better understanding of how this all works.


Well don't stop here explore Gentoo handbook or documentation or other guides for more fun stuff and if you hit any snags, drop a comment below, I'm here to help.
If this guide helped you, subscribe to the newsletter for more step-by-step tutorials.
1O1 out, I'll see you in the next one!

Load comments