FIX A PC

Simplified Gentoo Installation Tutorial UEFI

  • Estimated Time: 2 Hours
  • Number Of Commands:
  • Difficulty: 7
  • Requirements:
    • USB Drives
    • Internet Access
    • 2 Computers (For SSH access to copy and past commands)
    • Common Sense

 

Step 1: Download The Gentoo Minimal Install ISO, from Gentoo’s official downloads page

Download the installation media from the following Link to ensure you have the latest version before running using wget to download the .iso

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

Linux

wget http://distfiles.gentoo.org/releases/amd64/autobuilds/current-install-amd64-minimal/install-amd64-minimal-20200115T214501Z.iso

Windows

Download the file, by clicking the link.

Step 2: Creating The Gentoo Bootable USB Media

Linux

dd if=install-amd64-minimal-20200115T214501Z.iso of=/dev/sda bs=1M status=progress
(You must be in the same directory as you download the file)

Windows

Use Rufus to apply the iso to a USB device and make it bootable.

Step 3: Boot Installation Media

Insert the drive into your desired computer you wish to install Gentoo on and boot to the drive.

Step 4: Setting Up SSH Login And connecting

Start sshd service to be able to copy and past commands from your main computer to your Gentoo installation pc.

rc-service sshd start 
(Starts ssh daemon so that it can accept incoming connections)
passwd 
(Changed password for root when a user is not specified)
ssh 192.168.0.5 
(Connect to server, replace the ip with the machine you are installing Gentoo on)

Step 5: Partition Layout (GPT/UEFI)

Identify the hard drive you wish to install Gentoo on by issuing the following command

fdisk --list 
(Lists hard drives and other storage media)
parted /dev/sda 
(Launch partition utility on specified device)
mklabel gpt 
(Soft deletes all data on drive and creates a blank GPT partition layout
unit mb 
(Sets the specified numbers in the below commands to be treated as megabytes)
mkpart primary 1 3 
(Creates a partition the EFI legacy partition, not normally used and usually unneeded)
mkpart primary 3 1000 
(Creates the default EFI boot partition)
mkpart primary 1000 10000 
(Creates partition for swap space)
mkpart primary 10000 -1 
(Creates the main root partition)
set 1 bios_grub 
(Sets the first partition as the default legacy boot partition, again not normally used)
set 2 boot on 
(Turns on the boot flag for the main EFI boot partition)

Step 5: Filesystem Creation (GPT/UEFI)

mkfs.vfat -F 32 /dev/sda2 
(Creates a FAT 32 partition for /dev/sda2)
mkswap /dev/sda3 
(Creates swap filesystem on /dev/sda3)
swapon /dev/sda3 
(Turns on the swap filesystem for /dev/sda3)
mkfs.ext4 /dev/sda4 
(Creates a ext4 based partition on /dev/sda4)

 

Step 6: Mounting The Root Partition, Downloading And Extracting Stage 3 Archive.

mount /dev/sda4 /mnt/gentoo 
(Mounts and changes folder location on /mnt/gentoo to /dev/sda4)
ntpd -g -q 
(sets the time so downloaded stage3 files have correct date and time stamps)
cd /mnt/gentoo 
(navigates the terminal to the /mnt/gentoo folder that you mounted /dev/sda4 to)

Navigate to the Gentoo download page at the following link and copy the link of the stage 3 x86_64 archive, past it into the wget command below or use the link below with wget and update the OS later.

wget https://bouncer.gentoo.org/fetch/root/all/releases/amd64/autobuilds/20210224T214503Z/stage3-amd64-20210224T214503Z.tar.xz 
(Downloads stage3 to current directory, link from 2/25/2021)
tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner (extracts the downloaded stage 3 tar file regardless of version into its own directory structure inside of the /mnt/gentoo folder)
cp --dereference /etc/resolv.conf /mnt/gentoo/etc/ (Copys the nameservers currently in-use to the extracted gentoo OS files we are about to chroot into)

Step 7: Chroot Into Extracted Gentoo Filesystem, Mount Boot And Sync Package Manager)

mount --types proc /proc /mnt/gentoo/proc 
(Mounts the important sys processes to new stage 3 process folder)
mount --rbind /sys /mnt/gentoo/sys 
(Mounts system to new extracted /sys folder)
mount --rbind /dev /mnt/gentoo/dev 
(Mounts devices into the newly extracted OS)
mount --make-rslave /mnt/gentoo/sys
mount --make-rslave /mnt/gentoo/dev
chroot /mnt/gentoo 
(Roots the terminal environment inside the extracted Gentoo filesystem, you are now in your new OS)
source /etc/profile 
(Sources the profile)
export PS1="(chroot) ${PS1}" 
(Adds a chroot tag to your terminal prompt, not need but helps prevent execution of commands on wrong system due to human error)
mount /dev/sda2 /boot 
(Mounts the boot partition to the /boot folder)
emerge --sync 
(syncs repository / package manager with Gentoo servers)

Step 8: Update System Base, Time-Zone Configuration And Package Installation

emerge --ask --verbose --update --deep --keep-going --newuse @world (Updates system after your sync with the Gentoo repository, this part can be done later but i recommend updating the system before moving on to prevent package conflicts)
emerge app-portage/eix
(Used for searching packages with extra details, great for searching and installing testing versions)
eix-update 
(updates eix database with Gentoo's repository)
emerge sys-libs/timezone-data 
(Installs timezone data)
emerge app-eselect/eselect-timezone
(Add Gentoo's eselect ability for time-zone configuration)
eselect timezone list 
(Lists available time-zones, disregard the error, its because you not chosen a timezone yet)
eselect timezone set 581 
(Set the time-zone to US/Central time, or a desired one from the list)
emerge net-misc/openntpd 
(Installs the network time protocol and daemon, does not come installed by default like the live USB does - 2/25/2021)
emerge sys-apps/pciutils 
(Installs some basic commands for viewing system information, especially related to the pci bus system)
emerge app-admin/sysklogd 
(Installs log daemons to log system for troubleshooting)
emerge sys-process/cronie 
(Used for automating system tasks based on time, the Linux task scheduler)
emerge sys-kernel/genkernel 
(Kernel generation tool)
emerge app-portage/gentoolkit 
(Gentoo's default administration scripts, you wont get far without it)
emerge app-shells/gentoo-bashcomp 
(Expands the legendary tab key auto-complete capabilities)
emerge net-misc/dhcpcd 
(Required for wireless connection)
emerge net-wireless/wpa_supplicant 
(Required for wireless connection)
emerge sys-kernel/linux-firmware 
(Installs the default driver sets for Linux, still not sure why they use the word "firmware")
emerge sys-kernel/gentoo-sources 
(Installs the kernel sources, you need this to compile the kernel)
emerge sys-boot/grub 
(Installs the grub bootloader, you need this to boot your system)

Step 9: Turning On System Services At Start With Openrc

rc-update add ntpd 
(Runs the ntpd daemon at start to automatically update time with the internet)
rc-update add cronie 
(Adds the Linux task scheduler to startup)
rc-update add sysklogd 
(Adds the Linux logger daemon to startup)

Step 10: Fstab Configuration, Tune2fs Setup

For this step we are going to mount the partitions using the UUID to prevent incorrect mounts. First we will locate the UUID of the root partition and echo it into the Fstab file along with the boot partition.

blkid 
(copy the UUID of /dev/sda4 and replace the UUID of the command below)
echo "UUID="58e72203-57d1-4497-81ad-97655bd56494"    /    ext4    default    0 1" >> /etc/fstab
(Mounts /dev/sda4 as root, use YOUR UUID INSTEAD OF ONE PICTURED)
echo "UUID="41e634d1-5eb1-40e3-a217-d5461e5e55d3"    /boot    vfat    defaults    0 2" >> /etc/fstab 
(Mounts /dev/sda2 on boot folder after system starts, use YOUR UUID INSTEAD OF ONE PICTURED)
tune2fs -c 1 /dev/sda2
(Scans the boot partition's filesystem on each reboot for any inconsistences)
tune2fs -c 1 /dev/sda4
(Scans the root partition's filesystem on each reboot for any inconsistences)

Step 11: Kernel Configuration, Bootloader Installation And Set Root Pass

OPTION 1 
genkernel kernel --kernel-config=default --no-oldconfig
(Generates a kernel with Genkernel's default settings to ensure common drivers and options are installed.)
OPTION 2 
genkernel all --kernel-config=default --no-oldconfig --menuconfig
(Generates a kernel with Genkernel's default settings to ensure common drivers and options are installed. The --menuconfig option loads the kernel configuration utility commonly used when configuring your own kernel. If you need any drivers that are lesser used, you can select it in the utility here. This is what i normally use as i like the default config of Genkernel but i also need to add a few much options and drivers.)
grub-mkconfig -o /boot/grub/grub.cfg
(Generates the config for the grub bootloader) 
passwd
(Set a password for the default root account, this step must be completed if you want access to your system on reboot) 
reboot
(Reboots your system into your freshly installed Gentoo!, you can now follow links below if you would like to install Nvidia drivers, kernel based virtual machine, window or desktop manager.) 

 

%d bloggers like this: