User:Vadorovsky/Installation guide
My personal installation guide for a system with:
- LLVM as the main compiler, musl as libc.
- Encrypted ZFS as the root filesystem.
- OpenRC as init system.
- doas, nushell.
- COSMIC desktop.
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
/mnt/gentoo/etc/portage/make.conf
Portage configurationWARNING_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 corefonts cups dbus dist-kernel elogind flac flatpak fontconfig hardened icu jpeg jpeg2k kf6compat lcms libnotify lto networkmanager ogg opengl pdf pdfium pipewire policykit png pulseaudio qml qt6 security-key text tiif truetype udev unicode wayland webp video_cards_radeon vulkan vulkan-overlay x264 xcb xvfb zfs X -accessibility -systemd"
VIDEO_CARDS="amdgpu radeonsi"
CHOST="x86_64-pc-linux-musl"
LC_MESSAGES=C.utf8
Accept the license of linux-firmware:
/mnt/gentoo/etc/portage/package.license/kernel
Portage configurationsys-kernel/linux-firmware linux-fw-redistributable
Use dracut for generating initramfs:
/mnt/gentoo/etc/portage/package.use/kernel
Portage configurationsys-kernel/installkernel dracut
If you want to use the newest mainline kernel versions, accept the unstable versions of kernel and ZFS:
/etc/portage/package.accept_keywords/kernel
Portage configurationsys-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 sys-kernel/linux-firmware
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.
Rust
Installing software mentioned further requires Rust. Let's bootstrap Rust properly before proceeding.
Support for bootstraping Rust without GCC was merged just recently and didn't make it to stable ebuilds. Unmask the following packages:
/etc/portage/package.accept_keywords/rust
Portage configurationdev-lang/rust
dev-lang/rust-bin
llvm-runtimes/libgcc
The rust-bin package is masked for musl-llvm profile, so let's unmask it:
/etc/portage/package.mask/rust
Portage configuration-dev-lang/rust-bin
After that, we should be able to install Rust with
root #
emerge -av dev-lang/rust
nushell and other Rust tools
If you share my obsession about using Rust tools, you might want to install these:
root #
emerge -av app-shells/nushell app-shells/starship
And then add nushell as a shell, which can be set as a login shell:
/etc/shells
Shells/usr/bin/nu
Create user
root #
useradd -m -G users,wheel,audio -s /usr/bin/nu vadorovsky
root #
passwd vadorovsky
Install and configure doas:
root #
emerge -av app-admin/doas
/etc/doas.conf
doas configurationpermit :wheel
Install COSMIC desktop
Unmask COSMIC desktop packages:
/etc/portage/package.accept_keywords/cosmic-de
Unmasking unstable ebuildscosmic-de/*
Accept the license of corefonts:
/etc/portage/package.accept_keywords/cosmic-de
Unmasking unstable ebuildsmedia-fonts/corefonts MSttfEULA
Then install COSMIC, greetd and other necessary packages:
root #
emerge -av cosmic-meta pop-theme-meta gui-libs/display-manager-init gui-libs/greetd sys-auth/elogind
Configure greetd as a display manager:
/etc/conf.d/display-manager
greetd with cosmic-greeterCHECKVT=7
DISPLAYMANAGER="greetd"
Make sure that the following services are enabled:
root #
rc-update add elogind boot
root #
rc-update add dbus default
root #
rc-update add display-manager default
At the end, greetd needs to be configured to run cosmic-greeter as a frontend. It's very important to run it as cosmic-greeter user.
/etc/greetd/config.toml
greetd with cosmic-greeter[terminal]
vt = 7
[default_session]
command = "/usr/bin/cosmic-comp /usr/bin/cosmic-greeter"
user = "cosmic-greeter"