Written by Robert Whitney Category: Linux

  1. Introduction
  2. Configure the Network
    1. Manual Network Configuration
  3. SSHd
  4. Prepare your disk(s)
    1. Partition Disk(s)
  5. Create file systems and swap
  6. Mount the file system(s)
  7. Prepare the Stage
    1. Install the current portage snapshot
    2. Set your Timezone
    3. Select & Set System Profile
    4. Set Hostname
  8. Configure the Kernel
  9. Boot configuration
    1. /etc/fstab
  10. Grub2
  11. Finish Base Installation
    1. Merge Startup Packages
  12. Set Passwords


Gentoo is probably one of the most complicated, but rewarding, operating systems that I've ever ran. I know it's a lot of effort, but please don't allow the complexity of this guide, or the OS, scare you off.
That being said, let's dive in. You'll need to download Gentoo's minimal installation CD boot it up and follow the prompts until you get to a cli prompt.

Configure the Network

Output of ifconfig on Gentoo live CD. First, check with ifconfig that your network isn't already configured. If it is, move on to the next step.
If your netowrk is not configured, you will need to run net-setup <device> (in my case: net-setup enp16777736).

Manual Network Configuration

ifconfig enp16777736
route add default gw
echo 'nameserver' > /etc/resolv.conf


If you would like to take over the installation over your network, you can start the sshd & set the root password now, and then follow then rest of the installation steps over SSH.

/etc/init.d/sshd start

Prepare your disk(s)

Partition Disk(s)

You will need to use the command line tool, fdisk, to partition your disk, press m in fdisk for help.

fdisk /dev/sda #Partition your disks
fdisk -l /dev/sda #Check your partition table
When partitioning your disk, you should be sure to have at least a 150MB boot partition (Typically setup on /dev/sda1), a swap partition twice the size of your max memory (no more than 4GB recommended, typically on /dev/sda2), and your third partition (/dev/sda3) should be created with the remaining free space. After your disk is partitioned, we need to create the file systems.

Create file systems and swap

mkfs.ext2 /dev/sda1 #Setup a non-journaling file system for /boot.
mkswap /dev/sda2 && swapon /dev/sda2 #Create and mount swap
mkfs.ext4 /dev/sda3 #Create journaling file system for /.

Mount the file system(s)

Our next step is to mount & extract the stage 3 to our new filesystem

mount /dev/sda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot
cd /mnt/gentoo
wget http://distfiles.gentoo.org/releases/amd64/autobuilds/20191127T214502Z/stage3-amd64-20191127T214502Z.tar.xz #Make sure you get the current stage3 for your architecture
tar -xpf stage3*.tar.xz
Once your files are extracted, be sure that your ‘date’ command returns the correct UTC time, and if not fix it to match the correct UTC time (# date MMDDhhmmYYYY), after that is sorted we can chroot into our environment. If you are SSH’d into the system at this point, it is best to start a session in screen before you chroot.

cd /
mount -t proc proc /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev
mount --rbind /sys /mnt/gentoo/sys
cp -L /etc/resolv.conf /mnt/gentoo/etc/
chroot /mnt/gentoo /bin/bash
source /etc/profile

Prepare the Stage

Install the current portage snapshot

mkdir /usr/portage

Set your Timezone

ls /usr/share/zoneinfo #Using America/Chicago as example
cp /usr/share/zoneinfo/America/Chicago /etc/localtime
echo "America/Chicago" > /etc/timezone
date #check that the date is correct, else fix it

Select & Set System Profile

eselect profile list
Example output:

# eselect profile list
Available profile symlink targets:
[1]   default/linux/amd64/17.0 (stable)
[2]   default/linux/amd64/17.0/selinux (stable)
[3]   default/linux/amd64/17.0/hardened (stable)
[4]   default/linux/amd64/17.0/hardened/selinux (stable)
[5]   default/linux/amd64/17.0/desktop (stable)
[6]   default/linux/amd64/17.0/desktop/gnome (stable)
[7]   default/linux/amd64/17.0/desktop/gnome/systemd (stable)
[8]   default/linux/amd64/17.0/desktop/plasma (stable)
[9]   default/linux/amd64/17.0/desktop/plasma/systemd (stable)
[10]  default/linux/amd64/17.0/developer (stable)
[11]  default/linux/amd64/17.0/no-multilib (stable)
[12]  default/linux/amd64/17.0/no-multilib/hardened (stable)
[13]  default/linux/amd64/17.0/no-multilib/hardened/selinux (stable)
[14]  default/linux/amd64/17.0/systemd (stable)
[15]  default/linux/amd64/17.0/x32 (dev)
[16]  default/linux/amd64/17.1 (stable) *
[17]  default/linux/amd64/17.1/selinux (stable)
[18]  default/linux/amd64/17.1/hardened (stable)
[19]  default/linux/amd64/17.1/hardened/selinux (stable)
[20]  default/linux/amd64/17.1/desktop (stable)
[21]  default/linux/amd64/17.1/desktop/gnome (stable)
[22]  default/linux/amd64/17.1/desktop/gnome/systemd (stable)
[23]  default/linux/amd64/17.1/desktop/plasma (stable)
[24]  default/linux/amd64/17.1/desktop/plasma/systemd (stable)
[25]  default/linux/amd64/17.1/developer (stable)
[26]  default/linux/amd64/17.1/no-multilib (stable)
[27]  default/linux/amd64/17.1/no-multilib/hardened (stable)
[28]  default/linux/amd64/17.1/no-multilib/hardened/selinux (stable)
[29]  default/linux/amd64/17.1/systemd (stable)
[30]  default/linux/amd64/17.0/musl (exp)
[31]  default/linux/amd64/17.0/musl/hardened (exp)
[32]  default/linux/amd64/17.0/musl/hardened/selinux (exp)
[33]  default/linux/amd64/17.0/uclibc (exp)
[34]  default/linux/amd64/17.0/uclibc/hardened (exp)
Select your profile (your default USE flags are determined based on the profile that you set).

eselect profile set 16 #This would select "default/linux/amd64/17.1 (stable)"

Set Hostname

Your machine needs a name, or may be part of a domain, here you will get a chance to set that up

cd /etc
echo " nachos.tacos.intra nachos localhost" > hosts #replacing nachos with your machine name and tacos.intra with your actual domain (if you have one) of course.
sed -i -e 's/hostname.*/hostname="nachos"/' conf.d/hostname
hostname nachos
hostname -f #verify hostname is correct

Configure the Kernel

You could manually go in and make your kernel & initramfs, however I prefer to go the genkernel route. If you are comfortable with default kernel configuration you can just immediately exit the menuconfig on the genkernel step and skip right to building your kernel. If you decide to use systemd, however, then you will need to enable that in your kernel before you compile.

emerge -av gentoo-sources genkernel #replace gentoo-sources w/ hardened-sources if you selected a hardened profile.
genkernel --menuconfig all
It will take some time to build your kernel & modules, go ahead and grab a cup of coffee.

Boot configuration


blkid # this command will give you UUIDs for each partition
nano -w /etc/fstab #edit the fstab file
cat /etc/fstab #your fstab should look something like this:
/dev/sda1   /boot   ext2   noauto,noatime   1  2
/dev/sda3   /       ext4   noatime          0  1
/dev/sda2   none    swap   sw               0  0


Gentoo has made grub2 default for installation, it's a lot easier to setup than you might think.

emerge -av grub #if you are dual booting with Windows be sure to also install sys-boot/os-prober and sys-fs/ntfs3g
grub-install /dev/sda #Install to master boot record of first disk
grub-mkconfig -o /boot/grub/grub.cfg # Make grub configuration

Finish Base Installation

Merge Startup Packages

Unless you've opted to run systemd, you'll probably want some of the core packages such as a DHCP client, cron daemon, and system logging daemon. Here's a good starter kit that includes superadduser (a user add script) as well:
emerge -av dhcpcd syslog-ng anacron net-misc/ntp superadduser
# If you chose openrc (default) run these commands:
rc-update add dhcpcd default rc-update add syslog-ng default rc-update add anacron default rc-update add ntp-client default

Set Passwords

Now is a good time to add users and change your root password before you reboot into your new system.

passwd #change root password
superadduser username #replace username with your desired username, follow steps. You probably want your first user in the groups wheel, cron and portage.
You should be safe to reboot & install the rest of your systems packages now. Noticed an error in this article? Please leave a comment with any errors or deviations from the guide.