Gentoo Linux Installation Tutorial

The installation procedure for Gentoo involves more steps than other distributions. This is intentional so you can control the steps in a more clear way. Using this strategy, you can get started with less than 4GiB of disk and memory of down to 256MiB, 512MiB if you want to use the liveDVD. You also have the opportunity to tweak your system to be as efficient as you can make it. Your first try will be slower if you are not well versed in Linux and all the intricate details, but you can end up with a very lean system.

The media choices

Choosing where to start; As long as you have regular hardware and many times odd hardware, you should use the minimal installation CD to install. This method is also the Stage3 method. If all goes well, you will never bother with Stage1 and Stage2, but they are there for extreme install situations.

  • Minimal installation CD
  • The occasional Gentoo LiveDVD
  • Tarballs for installing exotic hardware or situations.

The tarballs

You can download compressed files that have a file system with files for the init system and basic packages. Pick one that suits your needs. If you are uncertain, take the ‘systemd’ one. This is the most common.

The other stage files are for advanced users. Developers mostly use the Stage1 and Stage2 files; if you do need them, you already know most of Gentoo.

First Boot

Download the minimal CD and burn it to a USB stick. You should consider adding the ISO file to a virtual machine and practice from there! Files are on the Gentoo site.

When the minimal CD boots, it will give you 15 seconds to choose a kernel. The intention of this is to handle a situation where the framebuffer does not work, or some other odd boot problems occur. If you do nothing, the system falls back to booting from the internal disk. If you have problems, you need to specify kernel parameters like the below.

$ gentoo scandelay

This takes the ‘gentoo’ kernel and sends the ‘scandelay’ option. Other options are a long list that you should investigate before you start, though this is not needed on most hardware.

You can also add users at this stage. These users will only work in the install system, so it is seldom useful.


To get started, you can do everything on a console but using a terminal has its advantages. If you want to do this, start sshd and set a password for the root user. Start by checking your IP address.

$ ip a

Then start sshd:

$ /etc/init.d/sshd start

Then set the password for the root user, or create a new temporary user.

$ passwd

You get a long printout that suggests a safe password. Handy if you have low energy or imagination. Now that you have both, you can ssh into your install system. One warning; when you start over from the CD, the ssh key will be re-created! Any key you have on your other system needs to be erased.

Preparing the disks

The disks are prepared as with many other distributions. To make it easier to follow the rest of their documentation, name your partitions as per the Gentoo standard. For a system that you will actually use, you should have a plan here. Preferably, one which has sizes for your ‘home’ as well as the ”. Necessary parts are the ‘/’ and the ‘/boot’. For UEFI, you should have 350 Megabytes of the disk for the boot files. Use your favorite partition editor. For the UEFI partition, use ‘mkfs.vfat -F 32 /dev/sda1’ and for the main use ‘mkfs.ext4 /dev/sda2’.

Mounting the main disks

You should have at least one boot disk of 350 MiB and one that will host your system as you start. A swap partition is also good to have. You can mount the with the standard command.

$ mount /dev/sda2 /mnt/gentoo

There is no reason to mount the ‘boot’ disk until you enter the chroot environment later. You can also mount user disks or partitions, but only if you are making the final system.

Downloading the tarballs

You can download the tarballs before you start or during install. Alternatively, the install environment has the ‘Links’ browser, so you can do it with the terminal. Download the files to the Gentoo disk.

$ cd /mnt/gentoo $ links

Once you have the files on your disk, unpack them with the tar command.

$ tar -xvf stage3-amd64-systemd-20210120T214504Z.tar.xz

Install base system

You actually have a very basic and generic system already; that is what the Stage3 file is all about. For example, you make.conf file is there with standard settings. It needs to have a mirror, though, set one using the tool.

$ mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf

It adds the value: GENTOOMIRRORS=”“, with your chosen mirrors, naturally. You also have an automatic option where you can specify protocol or speed constraints. There is also the deep option, where the tool actually downloads a 100KiB file to measure.

You also need an ebuild repository. This repository keeps track of what is available for upgrades. You can change this, which you will do when you look for a derivative of Gentoo. You can take the default from the newly created directory structure.

$ cd /mnt/gentoo $ mkdir –parents etc/portage/repos.conf $ cp usr/share/portage/config/repos.conf etc/portage/repos.conf/gentoo.conf

Usually, you do not change this. The cases when you do need to change it is when you have your own mirror. The below commands are directly from the website. They set up the environment for installing.

$ cp –dereference etc/resolv.conf /mnt/gentoo/etc $ 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

Now, you are prepared to move into the environment you are creating.

$ chroot /mnt/gentoo /bin/bash $ source /etc/profile $ export PS1="(chroot) ${PS1}"

Inside the environment, you also need to mount the boot partition.

$ mount /dev/sda2 /boot

Which partition this is should be clear from earlier steps. On a UEFI install, you have created the ESP where you store all boot information. Next, you download the repository information into the directory defined by your repos.conf file.

$ emerge-webrsync

Here you see the first mention of emerge. This command handles all your upgrades and installation. The next vital command you need to know about is eselect. With eselect, you read the latest news about Portage

$ eselect read news

Or choose your profile;

$ eselect profile list $ eselect profile set 3

You choose the number from the list or use the entire name you see in the list. Now you MUST set the @world set to ensure the system is updated according to your system, not the stage3 you used.

$ emerge –ask –verbose –update –deep –newuse @world

The most powerful variable in GENTOO! The USE variable sets what support needs to be compiled into your programs. Used correctly, you can make your system much leaner than with other methods. You can change this to stop supporting KDE if you are certain you will not run KDE. Gentoo will then compile all programs without that support, making the binary smaller. If you decide to switch to KDE, you have to start over and re-compile all your applications.

USE="-kde gnome qt5 alsa"

All of the values are set in the default values, so what you put is a change from the normal. The first time you build it is probably better just to get the system running.

Time zone and locales

Next, set the time zone. Fill in the values in the files.

$ ls usr/share/zoneinfo $ echo "Europe/Athens" > /etc/timezone

Use emerge to configure the time correctly.

$ emerge –config sys-libs/timezone-data

Add data in your locales file:

en_GB ISO-8859-1

en_GB.UTF-8 UTF-8

Configure using the file you just created.

$ locale-gen

This is the standard for all installs in the Linux world. This is the Gentoo specific:

$ eselect locale list $ eselect locale set 3

$ env-update && source /etc/profile && export PS1="(chroot) ${PS1}"

Automatic kernel configuration

Before you run the script, you must add your boot partition in the /etc/fstab file.

/dev/sda2      /boot    ext4    defaults      0  2

In Gentoo, you have the freedom to compile your own kernel for each machine you want to start. The better way to start is to get binary kernels that suit your needs. When you feel ready to get into the complexities of kernel compilation, do that on your running system. To pick a kernel, run emerge as always;

$ emerge –ask sys-kernel/gentoo-kernel-bin

The emerge command will install your kernel and set everything up!

Time to configure the system

Create the networking files.






$ emerge –ask net-misc/dhcpcd

This will install the dhcpcd program for handling dhcp. The default for Gentoo is dhcp.

Settings for dhcpcd using systemd are to enable the service.

$ systemctl –now enable net@enp1s0.service

Before you can boot into the new system, you need to have your boot loader installed. Here is how you choose GRUB2.

$ emerge –ask sys-boot/grub:2

$ grub-install /dev/sda –efi-directory=/boot

$ grub-mkconfig -o /boot/grub/grub.cfg

Now, you need to update your /etc/fstab file for the live system.


/dev/sda1               /boot           ext4            noauto,noatime  1 2

/dev/sda2               /               ext4            noatime         0 1

The ‘/dev/sda’ numbers will differ depending on your partitioning scheme. You can also use unique UUID numbers. You need to figure those out using the ‘blkid’ command.

Restart into your new system

You will now be able to boot into your live system. Remove the install media and try it out. If you have missed anything, you can always start over with the install media. Many problems are details, so you have all the files downloaded and can do only part of the installation. In that installation, you still have ’emerge’ available, and that is the tool you use for your upgrades and tweaking the system.


Gentoo does not have its own installer, which means you need to prepare what you want to achieve. You can do this by choosing the size of disks and investigating any specific needs for your system. If you want to get started quickly, you should choose a derivative and tweak from there until you feel certain that you can handle all details in a Linux system’s initial setup.

About the author

Mats Tage Axelsson

I am a freelance writer for Linux magazines. I enjoy finding out what is possible under Linux and how we can all chip in to improve it. I also cover renewable energy and the new way the grid operates. You can find more of my writing on my blog.