Gentoo Linux Installation Guide for Beginners – Part 1

Gentoo is a free and open-source Linux distribution known for its high performance, high reconfigurability, and stability. It uses the portage package management system for managing software packages.

Unlike major Linux distributions such as Ubuntu, Debian, or Red Hat, Gentoo does not provide an OS installer. Just like Arch Linux, Gentoo is built from the ground up and is considered one of the most complex operating systems to install.

Instead, Gentoo provides a comprehensive guide called Gentoo Handbook that walks you through the installation process. In this guide, we will demonstrate the installation of Gentoo using a Live GUI image. We will configure disk partitioning using an MBR partition scheme and a customized Kernel image provided by Gentoo developers.

This is the first part of a two-part series since the installation of Gentoo is quite lengthy. So, buckle up and enjoy the ride 🙂

1. Download Gentoo and Boot ISO Image

To kickstart this guide, head over to the Gentoo Download page and grab the last released LiveGUI ISO image.

With the Live image downloaded, reach out for your USB drive and use a tool such as Rufus to make a bootable medium from the ISO images or use popular USB creator tools to create a bootable USB medium from an ISO file.

Next, plug the USB drive into your PC and restart. Be sure to configure the BIOS and set the bootable medium to the highest boot priority. Once the system boots, this is what you will see on the screen. The first option comes pre-selected. So hit ENTER.

Gentoo GRUB Menu
Gentoo GRUB Menu

Thereafter, you’ll get a barrage of boot messages on your screen.

Gentoo Boot Messages
Gentoo Boot Messages

Finally, the Live GUI screen will come into view.

Gentoo KDE Plasma Desktop
Gentoo KDE Plasma Desktop

2. Configure Networking in Gentoo

If your system is already plugged into a network running a DHCP server using an Ethernet card, chances are that automatic network configuration has been set.

In this case, the active network interface has acquired a valid IP address from the DHCP server. If that’s the case, you’ll be able to run common network commands such as ping, ip, ifconfig, and ssh to mention a few.

In our case, the system has automatically acquired an IP address from the network via DHCP. To get started with working on the command line, switch to the root user.

sudo su

To check the IP address, we will run the command:

ip addr

From the output, you can see that the active interface (enp0s3) has obtained the IP 192.168.2.110 with a /24 CIDR.

Check Gentoo IP Address
Check Gentoo IP Address

You can check for internet connectivity using the ping command as follows.

$ ping -c 4 google.com

From the output, you can see that we get a positive reply from Google’s DNS.

Check Network Connection
Check Network Connection

3. Create Disk Partitions and Filesystems

The next step is to configure disk partitions and file systems. You can view the current partition layout using the fdisk command as shown.

$ fdisk /dev/sda

From the output, we have a system with a hard disk of 42.83GB.

Check Disk Partition Size
Check Disk Partition Size

You can configure your hard drive with either MBR for BIOS (Legacy Boot) configuration or GPT for UEFI.

In this guide, we will opt to create disk partitions with MBR for BIOS configuration.

Here is the disk partition layout.

/dev/sda1	1G	boot 
/dev/sda2 	4G	swap space
/dev/sda3	37G	Root partition

Create Boot Partition

To create the boot partition, type 'n' for the new partition. Then type 'p' to select the primary partition. Next, type 1 to specify the partition number. Alternatively, you can press ENTER since this is automatically selected for you. Hit ENTER when prompted for the First Sector.

Next, specify the disk size by prepending it with a (+) sign followed by the numeric size followed by 'G' for Gigabytes. You will get a confirmation that a new Linux partition has been created with the disk size specified.

Create Boot Partition
Create Boot Partition

Create Swap Space

To configure the swap space, repeat the same steps up to the first sector. Next, specify the disk size as +4G and hit ENTER.

Since the partition type created is of type ‘Linux‘, press 't' to change this to a different one. Provide the partition number (In this case '2') and then provide the code that corresponds to Swap (In this case 82).

NOTE: You can view all the partition types by typing 'L'.

Create Swap Partition
Create Swap Partition

Create Root Partition

For the root partition, specify the partition number as '3' or simply press ENTER to accept the default number (3), define the disk size (in this case +37G), and hit ENTER.

Create Root Partition
Create Root Partition

To view the partitions created, type 'p' and press ENTER. If you are satisfied with the partitions made, type 'w' and hit ENTER to save the disk partitions permanently.

List Partition Table
List Partition Table

After the partitions are created, the next step is to format them into the appropriate filesystems.

Linux supports a wide range of filesystems, some of which are only suited for specific purposes. Stable filesystems for amd64 systems include Ext3, Ext4, BTRFS, XFS, ZFS and ReiserFS.

For the /boot partition, we will format it as an EXT4 filesystem.

mkfs.ext4 /dev/sda1
Format Boot Partition with Ext4
Format Boot Partition with Ext4

To set up the swap partition, use the mkswap command as shown.

mkswap /dev/sda2

Then activate it using the swapon command.

swapon /dev/sda2
Setup Swap Partition
Setup Swap Partition

Lastly, format the root partition as an EXT4 filesystem.

mkfs.ext4 /dev/sda3
Format Root Partition with Ext4
Format Root Partition with Ext4

4. Mount the Root Partition

The next step is to mount the root partition. But first, let’s create a mount point for the partition.

mkdir --parents /mnt/gentoo 

The --parents option creates parent directories. Next, mount the partition using the command as shown.

mount /dev/sda3 /mnt/gentoo 
Mount Root Partition
Mount Root Partition

5. Configure Date and Time

Before installing Gentoo, ensure that the time and date settings are correct. To check the current date and time, run the date command.

date

If the date displayed is more than a few minutes off than what is expected, update the time automatically using the chronyd command-line utility.

chronyd -q

The command will rectify any existing time skew found. When you run the command again, you will notice that the time skew will be about 0.01 of a second which is a very slim difference that is not likely to impact any system processes or operations.

Set Date and Time in Gentoo
Set Date and Time in Gentoo

6. Download and Extract Gentoo Stage 3 Tarball File

A stage 3 tarball in Gentoo is simply an archive that ships with a profile-specific minimal Gentoo environment.

Downloading and decompressing the tarball file yields crucial system-wide directories such as /usr, /etc, /dev, /bin, /lib, /proc, /var, and many others which provide an almost complete functional system.

The only important parts that will be missing (and which will be installed in the second part of this guide) are the kernel and the bootloader.

To get started with extracting a stage 3 tarball file, navigate to the root directory.

cd /mnt/gentoo 

Run the command below to navigate to the Gentoo Mirror list

links https://www.gentoo.org/downloads/mirrors/

Select your preferred Country mirror, and hit ENTER.

Select Gentoo Mirror
Select Gentoo Mirror

Next, navigate to the ‘Releases‘ section.

Select Gentoo Release
Select Gentoo Release

Select the ‘amd64’ architecture option.

Select Gentoo Architecture
Select Gentoo Architecture

Next, select the `autobuilds` option.

Select Gentoo Autobuilds
Select Gentoo Autobuilds

Next, select the stage3 desktop systemd option since we are running a GUI system.

Select Gentoo Stage3
Select Gentoo Stage3

Navigate to the stage3 tarball file and hit ENTER to download it.

Download Gentoo Stage3
Download Gentoo Stage3

Choose the ‘Save’ option on the pop-up dialogue that appears.

Save Gentoo Stage3
Save Gentoo Stage3

Confirm the name of the file and press ENTER.

Confirm Gentoo Stage3
Confirm Gentoo Stage3

The download will start and a progress bar will indicate the download progress. This might take a while depending on the internet speed.

Downloading Gentoo Stage3
Downloading Gentoo Stage3

Once the download completes, select `Yes` to exit from the Gentoo Mirrors command-line interface.

Exit Gentoo Mirrors List
Exit Gentoo Mirrors List

Finally, unpack the downloaded stage tarball file to the system.

tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner

Once extracted, you will see additional system directories as shown.

Extract Gentoo Stage3
Extract Gentoo Stage3

This concludes Part 1 of the Gentoo installation guide. You now have a minimal Gentoo environment installed on your computer, but the installation process is far from complete. To proceed with the installation, follow the ‘Install Gentoo Linux – Part 2‘ tutorial.

Similar Posts