Gentoo

Preparation

1 - Go to the Gentoo Download page and download the latest iso. Official Installation Guide

2 - Boot your PC from Gentoo.

Check Internet Connection

ping -c 3 www.google.com

If networking didn't get configured automatically

ifconfig -a

net-setup adaptername

Partitioning

Fdisk or Gparted CD

fdisk -l

fdisk /dev/sda

p=print n=new t=type d=delete

create EFI, Swap / partitions

1=EFI(+512M) 19=swap(+2G)

w=write

mkfs.vfat -F32 /dev/sda1

mkswap /dev/sda2

swapon /dev/sda2

mkfs.ext4 /dev/sda3


mkdir --parents /mnt/gentoo

mount /dev/sda3 /mnt/gentoo

lsblk

Base System

Setting the date and time

date

ntpd -q -g

Stage Tarball

cd /mnt/gentoo

Download (Hardened SELinux) Stage d=download q=quit

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

Unpacking the stage tarball

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

Configuring Compile Options

nano -w /mnt/gentoo/etc/portage/make.conf

Add the changes below

# Compiler flags to set for all languages

COMMON_FLAGS="-march=native -O2 -pipe"

# Use the same settings for both variables

CFLAGS="${COMMON_FLAGS}"

CXXFLAGS="${COMMON_FLAGS}"

Chrooting

Selecting Mirrors (Optional)

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

Gentoo ebuild repository

mkdir --parents /mnt/gentoo/etc/portage/repos.conf

copy the Gentoo repository configuration file provided by Portage

cp /mnt/gentoo/usr/share/portage/config/repos.conf /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

Check the updated conf

cat /mnt/gentoo/etc/portage/repos.conf/gentoo.conf

Copy DNS info

cp --dereference /etc/resolv.conf /mnt/gentoo/etc/

Mount

mount --types proc /proc /mnt/gentoo/proc

mount --rbind /sys /mnt/gentoo/sys

mount --rbind /dev /mnt/gentoo/dev

mount --bind /run /mnt/gentoo/run

Entering the new environment

chroot /mnt/gentoo /bin/bash

source /etc/profile

export PS1="(chroot) ${PS1}"

Mounting the boot partition

mount /dev/sda1 /boot

lsblk

Configuring Portage

emerge-webrsync

eselect profile list

eselect profile set 4

emerge --ask --verbose --update --deep --newuse @world


nano -w /etc/portage/make.conf

Add the line below

ACCEPT_LICENSE="-* @BINARY-REDISTRIBUTABLE"


portageq envvar ACCEPT_LICENSE

Timezone

ls /usr/share/zoneinfo

echo "America/Chicago" > /etc/timezone

emerge --config sys-libs/timezone-data

Locale Generation

nano -w /etc/locale.gen

Add lines below

en_US ISO-8859-1

en_US.UTF-8 UTF-8


locale-gen


eselect locale list

eselect locale set numberhere

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

Configuring the Linux kernel

Linux Firmware

emerge --ask sys-kernel/linux-firmware

Linux Microcode

emerge --ask sys-firmware/intel-microcode

Sources

emerge --ask sys-kernel/gentoo-sources

eselect kernel list

eselect kernel set numberhere

ls -l /usr/src/linux

Distribution Kernel

(Prefered method here)

emerge --ask sys-kernel/installkernel-gentoo


emerge --ask sys-kernel/gentoo-kernel

Clean up old kernels

emerge --depclean

GenKernel

emerge --ask sys-kernel/genkernel


nano -w /etc/fstab

add the line below

/dev/sda1 /boot vfat defaults 0 2


genkernel all

ls /boot/vmlinu* /boot/initramfs*

make a note of kernel and initrd

Post-install/upgrade tasks

If required, manually trigger such rebuilds by, after a kernel upgrade, executing:

emerge --ask @module-rebuild

If any of these modules (e.g. ZFS) are needed at early boot, rebuild the initramfs afterward:

emerge --config sys-kernel/gentoo-kernel

use precompiled kernel images instead of compiling locally

emerge --config sys-kernel/gentoo-kernel-bin

Kernel Modules

Kernel modules (for exotic hardwares)

find /lib/modules/<kernel version>/ -type f -iname '*.o' -or -iname '*.ko' | less

mkdir -p /etc/modules-load.d


nano -w /etc/modules-load.d/network.conf

Modulename

Configuring the system

Fstab

lsblk

blkid


nano -w /etc/fstab

Example fstab file

/dev/sda1 /boot vfat noauto,noatime 0 2

/dev/sda2 none swap sw 0 0

/dev/sda3 / ext4 noatime 0 1

/dev/cdrom /mnt/cdrom auto noauto,user 0 0

Host & Domain Information

nano -w /etc/conf.d/hostname

Edit

# Set the hostname variable to the selected host name

hostname="namehere"


nano -w /etc/conf.d/net

Edit

# Set the dns_domain_lo variable to the selected domain name

dns_domain_lo="homenetwork"

If no domain name is configured, then users will notice they get "This is hostname.(none)" messages at their login screen. This should then be fixed by editing /etc/issue and deleting the string .\O from that file.

Network

emerge --ask net-misc/dhcpcd

rc-update add dhcpcd default

rc-service dhcpcd start

PCMCIA

emerge --ask sys-apps/pcmciautils

System information

Root Password

passwd

Init and boot configuration

nano -w /etc/rc.conf

nano -w /etc/conf.d/keymaps

nano -w /etc/conf.d/hwclock

Installing System Tools

System Logger

emerge --ask app-admin/sysklogd

rc-update add sysklogd default

Cron daemon

emerge --ask sys-process/cronie

rc-update add cronie default

File Indexing

emerge --ask sys-apps/mlocate

Time Synchronization

emerge --ask net-misc/chrony

rc-update add chronyd default

Filesystem Tools

emerge --ask filesystem/package

Ext4 sys-fs/e2fsprogs

XFS sys-fs/xfsprogs

ReiserFS sys-fs/reiserfsprogs

JFS sys-fs/jfsutils

VFAT(FAT32) sys-fs/dosfstools

Btrfs sys-fs/btrfs-progs

ZFS sys-fs/zfs

SSH

Only for Servers

rc-update add sshd default


nano -w /etc/inittab

Edit

# SERIAL CONSOLES

s0:12345:respawn:/sbin/agetty 9600 ttyS0 vt100

s1:12345:respawn:/sbin/agetty 9600 ttyS1 vt100

Bootloader

emerge --ask --verbose sys-boot/grub

echo 'GRUB_PLATFORMS="efi-64"' >> /etc/portage/make.conf

emerge --ask sys-boot/grub

grub-install --target=x86_64-efi --efi-directory=/boot

emerge --ask sys-boot/os-prober

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


exit

cd

umount -R /mnt/gentoo

reboot

Finalizing

useradd -m -G users,wheel,audio -s /bin/bash namehere

passwd namehere


emerge --ask app-admin/sudo

groupadd sudo

gpasswd -a username sudo

visudo /etc/sudoers

## Uncomment to allow members of group sudo to execute any command

%sudo ALL=(ALL) ALL


rm /stage3-*.tar.*

emerge --depclean