Linuxpad

Got Linux?

Gentoo Installation With Systemd-boot + Ugrd + Luks

Gentoo Installation With Systemd-boot + Ugrd + Luks

Gentoo Linux is a highly customizable and performance-focused Linux distribution that is known for its flexibility and source-based nature. Unlike most other Linux distributions, which typically distribute precompiled binary packages, Gentoo focuses on compiling packages from source code. This gives you more control over how the system is built and optimized, but also requires more time and effort to set up.

Gentoo has been my favorite Linux distribution due to it's unmatched customization and performance optimizations, making it a popular choice for enthusiasts, developers, and those who want to squeeze every bit of performance out of their hardware.

This setup provides a detailed guide to those users who are still on the fence about switching to Gentoo but cannot because many people find it hard to setup encryption in gentoo. This guide will be ideal for such people. Other guide like networking, adding users and other minor setups alike will still be consulted from the Gentoo Wiki page.

Now let's start the installation process!

Create new GPT table

Create new GPT partition table using fdisk command.

fdisk /dev/vda

Create encrypted LUKS volume

cryptsetup luksFormat /dev/vda2

Open LUKS volume

cryptsetup luksOpen /dev/vda2 crypt

Create LVM volume group

vgcreate volg /dev/mapper/crypt
lvcreate --name root -L 100G volg
lvcreate --name swap -L 18G volg
lvcreate --name home -l 100%free volg

Format the filesystems

mkfs.vfat /dev/vda1
mkfs.xfs /dev/volg/root
mkfs.xfs /dev/volg/home
mkswap /dev/volg/swap
swapon /dev/volg/swap

Mount paritions

mount /dev/volg/root /mnt/gentoo
mkdir /mnt/gentoo/{home,boot}
mount /dev/vda1 /mnt/gentoo/boot
mount /dev/volg/home /mnt/gentoo/home

Stage 3 and chroot

cd /mnt/gentoo
wget https://distfiles.gentoo.org/releases/amd64/autobuilds/20250115T221822Z/stage3-amd64-systemd-20250115T221822Z.tar.xz
tar xpvf stage3-*.tar.xz --xattrs-include='*.*' --numeric-owner -C /mnt/gentoo

Contine with system setup

Fetch repo data & keys

emerge-webrsync && getuto

LVM & cryptsetup


nano /etc/portage/package.use/system
sys-fs/lvm2 lvm
emerge --ask sys-fs/lvm2 sys-fs/cryptsetup
rc-update add lvm boot

Kernel install

nano /etc/portage/package.use/system

sys-kernel/installkernel ugrd systemd-boot systemd uki ukify
sys-apps/systemd-utils kernel-install boot ukify
emerge --ask --oneshot installkernel

systemd-boot

nano /etc/ugrd/config.toml

modules = [                                                                                                                                                                                                                                                                                                                                                     
  "ugrd.fs.fakeudev",                                                                                                                                                                           
]

Install

bootctl install

fstab

nano /etc/fstab

UUID=of boot_drive eg vda1 /boot vfat umask=0077 0 2

/dev/volg/root /     xfs defaults,noatime 0 1
/dev/volg/home /home xfs defaults,noatime 0 2

/dev/volg/swap none swap sw 0 0

Kernel

touch /etc/kernel/cmdline
emerge --ask gentoo-kernel-bin

Continue installaltion of Firmware From the Wiki