Written 2019-12-02 16:00:00 +0000 by Robert Whitney Category: Linux
This guide is not frequently updated. If you notice that you need to deviate fromt his guide for any reason then please let me know in the comments below. :)
This page last updated
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.
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:
ifconfig enp16777736 192.168.1.2/24 route add default gw 192.168.1.1 echo 'nameserver 192.168.1.1' > /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 passwd
You will need to use the command line tool, fdisk, to partition your disk, press m in fdisk for help.
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.
fdisk /dev/sda #Partition your disks fdisk -l /dev/sda #Check your partition table
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 /.
Our next step is to mount & extract the stage 3 to our new filesystem
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.
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
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
mkdir /usr/portage emerge-webrsync
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
eselect profile list
Select your profile (your default USE flags are determined based on the profile that you set).
# eselect profile list Available profile symlink targets:  default/linux/amd64/17.0 (stable)  default/linux/amd64/17.0/selinux (stable)  default/linux/amd64/17.0/hardened (stable)  default/linux/amd64/17.0/hardened/selinux (stable)  default/linux/amd64/17.0/desktop (stable)  default/linux/amd64/17.0/desktop/gnome (stable)  default/linux/amd64/17.0/desktop/gnome/systemd (stable)  default/linux/amd64/17.0/desktop/plasma (stable)  default/linux/amd64/17.0/desktop/plasma/systemd (stable)  default/linux/amd64/17.0/developer (stable)  default/linux/amd64/17.0/no-multilib (stable)  default/linux/amd64/17.0/no-multilib/hardened (stable)  default/linux/amd64/17.0/no-multilib/hardened/selinux (stable)  default/linux/amd64/17.0/systemd (stable)  default/linux/amd64/17.0/x32 (dev)  default/linux/amd64/17.1 (stable) *  default/linux/amd64/17.1/selinux (stable)  default/linux/amd64/17.1/hardened (stable)  default/linux/amd64/17.1/hardened/selinux (stable)  default/linux/amd64/17.1/desktop (stable)  default/linux/amd64/17.1/desktop/gnome (stable)  default/linux/amd64/17.1/desktop/gnome/systemd (stable)  default/linux/amd64/17.1/desktop/plasma (stable)  default/linux/amd64/17.1/desktop/plasma/systemd (stable)  default/linux/amd64/17.1/developer (stable)  default/linux/amd64/17.1/no-multilib (stable)  default/linux/amd64/17.1/no-multilib/hardened (stable)  default/linux/amd64/17.1/no-multilib/hardened/selinux (stable)  default/linux/amd64/17.1/systemd (stable)  default/linux/amd64/17.0/musl (exp)  default/linux/amd64/17.0/musl/hardened (exp)  default/linux/amd64/17.0/musl/hardened/selinux (exp)  default/linux/amd64/17.0/uclibc (exp)  default/linux/amd64/17.0/uclibc/hardened (exp)
eselect profile set 16 #This would select "default/linux/amd64/17.1 (stable)"
cd /etc echo "127.0.0.1 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
It will take some time to build your kernel & modules, go ahead and grab a cup of coffee.
emerge -av gentoo-sources genkernel #replace gentoo-sources w/ hardened-sources if you selected a hardened profile. genkernel --menuconfig all
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
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
emerge -av dhcpcd syslog-ng anacron net-misc/ntp superadduser rc-update add dhcpcd default rc-update add syslog-ng default rc-update add anacron default rc-update add ntp-client default
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.
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.