User:Xerxeslins/Simplified Installation of Gentoo
This article is a summary for reference, which removes much of the information from the Handbook to meet a specific case: installing Gentoo using ext4 file system, Systemd, GRUB, GPT/UFI, no encryption, KDE Plasma, all system directories on a single partition (except for efi partition). It serves as a superficial guide and reminder of the installation process that can perhaps help you in some way. But if you want "generic" content that adapts to all situations, the best option would be to read the Handbook.
Article tested on a modest personal computer:
- AMD Ryzen 7 3700X
- 32 GB RAM SSD4
- 128 GB NVMe SSD
- GPU RADEON R5220 2 GB
Download a ISO
To get started, download the minimal Gentoo installation ISO or use another distro like SystemRescue:
The advantage of SystemRescue is that you will have a graphical environment, browser and several tools.
Burn the ISO to a USB device and boot from it.
Partitions
Create two partitions:
- 300 MB for UEFI ESP
- And the rest to the root
For that, use "gdisk".
root #
gdisk /dev/nvme0n1
Create the GPT partition table: Command: o ↵ This option deletes all partitions and creates a new protective MBR. Proceed? (Y/N): y ↵ Create partition 1 (UEFI ESP): Command: n ↵ Partition Number: 1 ↵ First sector: ↵ Last sector: +300M ↵ Hex Code: ef00 ↵ Create partition 2 (root): Command: n ↵ Partition Number: 2 ↵ First sector: ↵ Last sector: ↵ Hex Code: ↵ Write the partition table on the disk: Command: w ↵ Do you want to proceed? (Y/N): Y ↵
We will not create a swap partition. It can be created in a file later.
Format partitions:
root #
mkfs.ext4 /dev/nvme0n1p2
root #
mkfs.vfat -F 32 /dev/nvme0n1p1
Mount partitions:
root #
mkdir -p /mnt/gentoo
root #
mount /dev/nvme0n1p2 /mnt/gentoo
root #
mkdir -p /mnt/gentoo/boot/efi
root #
mount /dev/nvme0n1p1 /mnt/gentoo/boot/efi
Stage 3
To download and extract stage3 proceed with:
root #
cd /mnt/gentoo
Visit: https://www.gentoo.org/downloads/
Copy the link from Stage3: desktop profile with systemd. This article was designed for Systemd.
root #
wget -c <copied link>
If you are in text mode, you can use the browser links to download the file.
Extract with the correct permissions:
root #
tar --xattrs-include='*.*' --numeric-owner -xpf stage3*
Chroot
Now let's chroot:
root #
cd /mnt/gentoo
root #
mount --types proc /proc /mnt/gentoo/proc
root #
mount --rbind /sys /mnt/gentoo/sys
root #
mount --make-rslave /mnt/gentoo/sys
root #
mount --rbind /dev /mnt/gentoo/dev
root #
mount --make-rslave /mnt/gentoo/dev
root #
mount --bind /run /mnt/gentoo/run
root #
mount --make-slave /mnt/gentoo/run
root #
cp /etc/resolv.conf etc && chroot . /bin/bash
root #
source /etc/profile
One line:
root #
cd /mnt/gentoo; 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; mount --bind /run /mnt/gentoo/run; mount --make-slave /mnt/gentoo/run; cp /etc/resolv.conf etc && chroot . /bin/bash; source /etc/profile
Sync and User Creation
Sync with Gentoo repository:
root #
emerge-webrsync
Create the root password and a new user.
The line below is optional and is for Gentoo to accept weak passwords.
root #
sed -i s/everyone/none/ /etc/security/passwdqc.conf
Root password:
root #
passwd
Creating your user:
root #
useradd -g users -G wheel,portage,audio,video,usb,cdrom -m <user>
root #
passwd <user>
Fstab Configuration
Check the UUID of the root partition.
root #
blkid | grep nvme0n1p2
Edit fstab:
root #
nano /etc/fstab
Add the line referring to the root partition, based on the UUID. Example:
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx / ext4 noatime 0 1
make.conf
Edit make.conf :
root #
nano /etc/portage/make.conf
Example:
# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
COMMON_FLAGS="'''-march=native''' -O2 -pipe"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
# NOTE: This stage was built with the bindist Use flag enabled
PORTDIR="/var/db/repos/gentoo"
DISTDIR="/var/cache/distfiles"
PKGDIR="/var/cache/binpkgs"
# Please keep this setting intact when reporting bugs.
LC_MESSAGES=C
'''VIDEO_CARDS="radeon r600"'''
'''ACCEPT_LICENSE="*"'''
'''MAKEOPTS="-j16"'''
'''USE="pulseaudio"'''
The most important things here is:
COMMON_FLAGS="'''-march=nativ'''e -O2 -pipe"
The "-march=native" flag will instruct the compiler to produce code specific to the system CPU, with all its features, instruction sets, quirks, etc.
'''VIDEO_CARDS="radeon r600"'''
Instructs the system to use the correct driver for your video card. See which one is yours at: Category:Video_cards
'''ACCEPT_LICENSE="*"'''
For Portage to automatically accept software licenses. See more at: /etc/portage/make.conf#ACCEPT_LICENSE
'''MAKEOPTS="-j16"'''
MAKEOPTS is a variable that defines how many parallel jobs can be started by Portage. Depends on the number of CPU cores. See more at: MAKEOPTS
'''USE="pulseaudio"'''
PulseAudio is a sound server. It is important to allow controlling the sound in KDE Plasma.
After editing make.conf, save and exit.
Localization
Edit the locale.gen :
root #
nano /etc/locale.gen
Uncomment the line you want or add it. Example:
pt_BR.UTF8 UTF-8
Save and exit. Run:
root #
locale-gen
root #
eselect locale list
root #
eselect locale set <number>
Check the available X11 keymap layouts:
root #
localectl list-x11-keymap-layouts
Set the keymap layout:
root #
localectl set-x11-keymap br-abnt2
Check if the X11 keymap layout was set correctly:
root #
localectl | grep "X11 Layout"
X11 Layout: br-abnt2
Timezone:
root #
ln -sf /usr/share/zoneinfo/America/Recife /etc/localtime
change "America/Recife" to your state capital.
root #
emerge --config sys-libs/timezone-data
Kernel
Install kernel and firmware:
root #
emerge sys-kernel/gentoo-kernel-bin
root #
emerge sys-kernel/linux-firmware x11-drivers/xf86-input-evdev
in another article I will explain how to install the latest version of the Linux kernel. For now, to get a usable system quickly, the binary kernel is a good option.
GRUB
Emerge the GRUB:
root #
emerge --ask grub
Install GRUB and configure:
root #
grub-install --target=x86_64-efi --efi-directory=/boot/efi
root #
grub-mkconfig -o /boot/grub/grub.cfg
Desktop Profile
Change the profile to "desktop/plasma/systemd (stable)":
root #
eselect profile list
root #
eselect profile set <number>
Utilities
Useful apps:
root #
emerge --ask gentoolkit eix flaggie layman genlop
Look up each one on the Gentoo wiki if you don't know what they are for.
KDE Plasma and Browser
Full KDE Plasma and Firefox:
root #
emerge kde-plasma/plasma-meta kde-apps/kde-apps-meta www-client/firefox-bin
Enable SDDM:
root #
systemctl enable sddm
Enable NetworkManager:
root #
systemctl enable NetworkManager
If you want to change the computer name:
root #
hostnamectl hostname <new name>
Machine ID
Create a machine ID for journaling to work:
root #
systemd-machine-id-setup
Reboot
Finishing up:
root #
exit
root #
cd /mnt
root #
umount -lR gentoo
root #
reboot