User:Vadorovsky/Installation guide

From Gentoo Wiki
Jump to:navigation Jump to:search

My personal installation guide for a system with:

Preparing the disk(s)

Creating partitions

Use fdisk to create two partitions:

  • EFI partition - 1GB.
  • root partition - the rest of space.

Create EFI filesystem

root #mkfs.vfat -F 32 /dev/nvme0n1p1

Generate host ID

root #zgenhostid -f

Create ZFS filesystem

root #zpool create -f \
-o ashift=12 \
-o autotrim=on \
-O acltype=posixacl \
-O xattr=sa \
-O relatime=on \
-O compression=lz4 \
-O encryption=aes-256-gcm \
-O keylocation=prompt \
-O keyformat=passphrase \
-m none tank /dev/nvme0n1p2
root #zfs create -o mountpoint=none tank/os
root #zfs create -o mountpoint=/ -o canmount=noauto tank/os/gentoo
root #zfs create -o mountpoint=/home tank/home
root #zpool set bootfs=tank/os/gentoo tank

Mount the filesystems

root #mkdir -p /mnt/gentoo
root #zpool export tank
root #zpool import -N -R /mnt/gentoo tank
root #zfs mount -l tank/os/gentoo
root #zfs mount tank/home
root #mkdir -p /mnt/gentoo/efi
root #mount /dev/nvme0n1p1 /mnt/gentoo/efi

Download and unpack stage3

Download the newest musl-llvm stage3 archive you can find on this page:

Then extract it:

root #tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner -C /mnt/gentoo

Copy configuration files

root #cp /etc/hostid /mnt/gentoo/etc
root #cp --dereference /etc/resolv.conf /mnt/gentoo/etc/

Configure portage

We need to configure Portage to:

  • Enable native builds.
  • Enable ThinLTO.

By editing the file:

root #nano /mnt/gentoo/etc/portage/make.conf
FILE /mnt/gentoo/etc/portage/make.confPortage configuration
WARNING_FLAGS="-Werror=odr -Werror=strict-aliasing"
COMMON_FLAGS="-O2 -pipe -march=native -flto=thin ${WARNING_FLAGS}"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"

RUSTFLAGS="${RUSTFLAGS} -Clinker-plugin-lto"

USE="alsa bluetooth cairo cups dbus dist-kernel elogind flatpak hardened icu kf6compat lto networkmanager opengl pdfium pipewire policykit pulseaudio qt6 security-key text udev wayland video_cards_radeon vulkan vulkan-overlay zfs X -accessibility -systemd"
VIDEO_CARDS="amdgpu radeonsi"

CHOST="x86_64-pc-linux-musl"

LC_MESSAGES=C.utf8

Accept the license of linux-firmware:

FILE /mnt/gentoo/etc/portage/package.license/kernelPortage configuration
sys-kernel/linux-firmware linux-fw-redistributable

Use dracut for generating initramfs:

FILE /mnt/gentoo/etc/portage/package.use/kernelPortage configuration
sys-kernel/installkernel dracut

If you want to use the newest mainline kernel versions, accept the unstable versions of kernel and ZFS:

FILE /etc/portage/package.accept_keywords/kernelPortage configuration
sys-fs/zfs
sys-fs/zfs-kmod
sys-kernel/gentoo-kernel
sys-kernel/linux-firmware
virtual/dist-kernel

Chroot

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 #env -i chroot /mnt/gentoo /bin/bash
root #env-update
root #source /etc/profile

Fetch repos

First do it the usual way:

root #emerge-webrsync

Install first dependencies, which will let us configure repositories:

root #emerge -av app-eselect/eselect-repository dev-vcs/git

Then switch to git:

root #eselect repository disable gentoo
root #eselect repository enable gentoo
root #rm -r /var/db/repos/gentoo

Add more repositories:

root #eselect repository enable guru
root #eselect repository add cosmic-overlay git https://github.com/fsvm88/cosmic-overlay.git
root #eselect repository add vadorovsky git https://github.com/vadorovsky/overlay.git

Then sync them:

root #emerge --sync

Install base system

First of all, upgrade @world to catch the USE flags changed in our configuration.

root #emerge -avuDN @world

Install kernel:

root #emerge -av sys-kernel/gentoo-kernel

Install ZFS:

root #emerge -av sys-fs/zfs sys-fs/zfs-kmod

Then rebuild initramfs, to include the ZFS module in it:

root #emerge --config sys-kernel/gentoo-kernel

Bootloader

We are going to use ZFSBootMenu.

root #mkdir -p /efi/EFI/BOOT
root #curl -L https://get.zfsbootmenu.org/efi -o /efi/EFI/BOOT/BOOTX64.EFI

Configure system

Set root password

root #passwd

Set hostname

root #echo tux > /etc/hostname

Set keymap

Setup system tools

sysklogd:

root #emerge --ask app-admin/sysklogd
root #rc-update add sysklogd default

Reboot

After that, we can reboot the system.

Create user

root #useradd -m -G users,wheel,audio -s /bin/bash vadorovsky
root #passwd vadorovsky

Install and configure doas: