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.
Thereafter, you’ll get a barrage of boot messages on your screen.
Finally, the Live GUI screen will come into view.
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.
To check the IP address, we will run the command:
From the output, you can see that the active interface (enp0s3) has obtained the IP 192.168.2.110 with a /24 CIDR.
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.
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.
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 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
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.
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.
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.
To set up the swap partition, use the mkswap command as shown.
Then activate it using the swapon command.
Lastly, format the root partition as an EXT4 filesystem.
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
--parents option creates parent directories. Next, mount the partition using the command as shown.
mount /dev/sda3 /mnt/gentoo
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.
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.
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.
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.
Run the command below to navigate to the Gentoo Mirror list
Select your preferred Country mirror, and hit ENTER.
Next, navigate to the ‘Releases‘ section.
Select the ‘amd64’ architecture option.
Next, select the `autobuilds` option.
Next, select the stage3 desktop systemd option since we are running a GUI system.
Navigate to the stage3 tarball file and hit ENTER to download it.
Choose the ‘Save’ option on the pop-up dialogue that appears.
Confirm the name of the file and press ENTER.
The download will start and a progress bar will indicate the download progress. This might take a while depending on the internet speed.
Once the download completes, select `Yes` to exit from the Gentoo Mirrors command-line interface.
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.
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.