diff --git a/docs/gentoo-desktop-setup/graphical-session/login-manager.md b/docs/gentoo-desktop-setup/graphical-session/login-manager.md index 8aab403..46bba66 100644 --- a/docs/gentoo-desktop-setup/graphical-session/login-manager.md +++ b/docs/gentoo-desktop-setup/graphical-session/login-manager.md @@ -23,7 +23,7 @@ gui-apps/gtkgreet ~amd64 Then emerge River and the `greetd` components: ``` -root@host:~# emerge -av river gtkgreet greetd display-manager-init swaybg +sh# emerge -av river gtkgreet greetd display-manager-init swaybg ``` Now `greetd` has to be configured to launch River with `gtkgreet`. Besides that styling `gtkgreet` can be done using css files and GTK themes and using this configuration a wallpaper which resides at `/etc/greetd/current_wallpaper.png`. @@ -102,7 +102,7 @@ DISPLAYMANAGER="greetd" Then enable the `display-manager` service to start on boot: ``` -root@host:~# rc-update add display-manager default +sh# rc-update add display-manager default ``` > Before enabling the `display-manager` service it is recommend to simply first start it ones to see if it works. diff --git a/docs/gentoo-desktop-setup/graphical-session/session-manager.md b/docs/gentoo-desktop-setup/graphical-session/session-manager.md index 8e363a1..74ad955 100644 --- a/docs/gentoo-desktop-setup/graphical-session/session-manager.md +++ b/docs/gentoo-desktop-setup/graphical-session/session-manager.md @@ -1,21 +1,20 @@ Session management is necessary for tracking and giving rights to certain users. For a functional setup install both `elogind` and `turnstile` and enable their corresponding services. ``` shell-session -root@host:~# emerge -av elogind turnstile -root@host:~# rc-update add elogind boot -root@host:~# rc-update add turnstiled +sh# emerge -av elogind turnstile +sh# rc-update add elogind boot +sh# rc-update add turnstiled ``` -Then configure `pam` to allow them to track the user: +Then configure `pam` to turnstile to track the user: ``` shell title="/etc/pam.d/system-login" ... -session optional pam_elogind.so session optional pam_turnstile.so ``` When a user logs in it should now be able to start a graphical session. This should be done with: ``` shell-session -user@host:~$ dbus-run-session -- +sh$ dbus-run-session -- ``` diff --git a/docs/gentoo-desktop-setup/installation.md b/docs/gentoo-desktop-setup/installation.md index ed9a44c..a9975e2 100644 --- a/docs/gentoo-desktop-setup/installation.md +++ b/docs/gentoo-desktop-setup/installation.md @@ -3,25 +3,25 @@ Now is the time to actually install Gentoo. First import the pool again: ``` shell-session -root@host:~# zpool import -N -R /mnt rpool -root@host:~# zfs load-key -L file:///tmp/rpool.key rpool +sh# zpool import -N -R /mnt rpool +sh# zfs load-key -L file:///tmp/rpool.key rpool ``` Then mount the datasets and the ESP on `/mnt`: ``` shell-session -root@host:~# mount -t zfs rpool/root/gentoo /mnt -root@host:~# mkdir /mnt/var -root@host:~# mount -t zfs rpool/root/gentoo/var /mnt/var -root@host:~# mkdir /mnt/efi -root@host:~# mount -t vfat /dev/disk/by-label/esp /mnt/efi +sh# mount -t zfs rpool/root/gentoo /mnt +sh# mkdir /mnt/var +sh# mount -t zfs rpool/root/gentoo/var /mnt/var +sh# mkdir /mnt/efi +sh# mount -t vfat /dev/disk/by-label/esp /mnt/efi ``` Now we're going to fetch a stage3 tarball for on the root of the system. Replace the `` with the latest tarball release. ``` shell-session -root@host:~# cd /mnt -root@host:/mnt# wget https://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-musl-hardened/stage3-amd64-musl-hardened-.tar.xz +sh# cd /mnt +sh# wget https://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-musl-hardened/stage3-amd64-musl-hardened-.tar.xz ``` This should have placed a tarball at `/mnt/stage3-amd64-musl-hardened-*-.tar.xz`. There are also other mirrors like `https://ftp.snt.utwente.nl/pub/os/linux/gentoo/releases/amd64/autobuilds/current-stage3-amd64-musl-hardened/` which might provide a faster download depending on your location. Check out for other mirrors. @@ -31,16 +31,18 @@ This should have placed a tarball at `/mnt/stage3-amd64-musl-hardened-*-.tar.xz` Unpack it in the new root: ``` shell-session -root@host:/mnt# tar xpvf stage3-*.tar.xz --numeric-owner -C /mnt +sh# tar xpvf stage3-*.tar.xz --numeric-owner -C /mnt ``` Then before finally chrooting into the system simply copy over the `resolv.conf` for internet connection inside the chroot. ``` shell-session -root@host:/# cp /etc/resolv.conf /mnt/etc/. -root@host:/# cp /tmp/rpool.key /mnt/tmp -root@host:/# for i in dev proc sys run; do mount --rbind --make-rslave /$i /mnt/$i; done -root@host:/# chroot /mnt +sh# cp /etc/resolv.conf /mnt/etc/. +sh# cp /tmp/rpool.key /mnt/tmp +sh# for i in dev proc sys run; do +> mount --rbind --make-rslave /$i /mnt/$i +> done +sh# chroot /mnt ``` ## Configuring the system @@ -100,11 +102,11 @@ MODULES_SIGN_HASH="sha512" Now finally sync the repositories and try installing a package like `vim`. ``` shell-session -root@chroot:~# emaint sync +sh# emaint sync ... Action: sync for repo: gentoo, returned code = 0 -root@chroot:~# emerge --ask --verbose app-editors/vim +sh# emerge --ask --verbose app-editors/vim >>> Completed (3 of 4) app-editors/vim-*::gentoo ``` @@ -128,7 +130,7 @@ proc /proc proc nodev,nosuid,noexec,hidepid=2 Musl does not come with timezone's installed by default. Install `timezone-data` with: ``` shell-session -root@chroot:~# emerge -av sys-libs/timezone-data +sh# emerge -av sys-libs/timezone-data ``` Select the correct timezone with: @@ -140,15 +142,15 @@ TZ="/usr/share/zoneinfo//" Update the environment of your shell-session: ``` shell-session -root@chroot:~# env-update && source /etc/profile +sh# env-update && source /etc/profile ``` To sync your system's time with a server set up a *Network Time Protocol daemon*. It's recommended to use OpenBSD's `openntpd` which aims to be as secure and minimal as possible: ``` shell-session -root@chroot:~# emerge -av net-misc/openntpd -root@chroot:~# rc-update add ntpd default -root@chroot:~# rc-service ntpd start +sh# emerge -av net-misc/openntpd +sh# rc-update add ntpd default +sh# rc-service ntpd start ``` ### Set up locales @@ -156,7 +158,7 @@ root@chroot:~# rc-service ntpd start Musl also does not support locales out of the box. They aren't necessary but some programs rely on them to set the language of their application. To be able to use locales install the `musl-locales` package: ``` shell-session -root@chroot:~# emerge -av sys-apps/musl-locales +sh# emerge -av sys-apps/musl-locales ``` And to allow the system to know where the locales are located: @@ -168,9 +170,9 @@ MUSL_LOCPATH="/usr/share/i18n/locales/musl" There are a multiple locales to choose from. In most situations choosing `en_US` is the standard but selecting a different one should not break the system. Choose the desired locale with $n \in \mathbb{N}$: ``` shell-session -root@chroot:~# eselect locale list -root@chroot:~# eselect locale set -root@chroot:~# env-update && source /etc/profile +sh# env-update && source /etc/profile +sh# eselect locale list +sh# eselect locale set ``` ### Setting the hostname @@ -178,7 +180,7 @@ root@chroot:~# env-update && source /etc/profile The system's hostname is the name given to the machine. Other systems on a network will also be able to see this name. To set it replace with the desired name: ``` shell-session -root@chroot:~# echo "" > /etc/hostname +sh# echo "" > /etc/hostname ``` ### Internet @@ -193,7 +195,7 @@ net-dns/dnsmasq dnssec Also make sure the `networkmanager` USE flag is enabled in your `make.conf`. Then emerge `networkmananger` and `dnsmasq`: ``` shell-session -root@chroot:~# emerge -av net-misc/networkmanager net-dns/dnsmasq +sh# emerge -av net-misc/networkmanager net-dns/dnsmasq ``` Now configure NetworkManager and Dnsmasq. This is a generally secure recommended setup: @@ -225,7 +227,7 @@ dnssec-check-unsigned Then disable any other network services before enabling the `NetworkManager`service: ``` shell-session -root@chroot:~# rc-update add NetworkManager default +sh# rc-update add NetworkManager default * service NetworkManager added to runlevel default ``` @@ -234,9 +236,9 @@ root@chroot:~# rc-update add NetworkManager default GURU is an extra repository which contains packages not available in the main Gentoo repository. Although the packages it contains might not be as well tested as in the main repo they are still necessary for some setups. Add Guru with: ``` shell-session -root@chroot:~# emerge -av app-eselect/eselect-repository -root@chroot:~# eselect repository enable guru -root@chroot:~# emaint sync --repo guru +sh# emerge -av app-eselect/eselect-repository +sh# eselect repository enable guru +sh# emaint sync --repo guru ``` To allow unstable packages from GURU set the `~amd64` keyword for it: @@ -252,7 +254,7 @@ To allow unstable packages from GURU set the `~amd64` keyword for it: `sbctl` is a simple tool which allows for the management of Secureboot settings on a system. It can create, deploy and sign keys with ease. First off install `sbctl`: ``` shell-session -root@chroot:~# emerge -av sbctl +sh# emerge -av sbctl ``` > Verify that Secureboot mode is on and in setup mode with `sbctl status` @@ -260,12 +262,12 @@ root@chroot:~# emerge -av sbctl Then create and enroll keys into the system. ``` shell-session -root@chroot:~# sbctl create-keys +sh# sbctl create-keys Created Owner UUID abcde.... Creating secure boot keys...✔ Secure boot keys created! -root@chroot:~# sbctl enroll-keys <--microsoft> +sh# sbctl enroll-keys <--microsoft> ... Enrolled keys to the EFI variables! ``` @@ -277,8 +279,8 @@ Use the `--microsoft` flag if the system is unable to use custom keys or when du `zlevis` is able to unlock an encrypted ZFS root pool with keys saved in a TPM, currently it's only available in the `portage-ample` repository and also has some dependencies in the `guru` repository. Add the `portage-ample` repository with: ``` shell-session -root@chroot:~# eselect repository add portage-ample git https://git.bijl.us/lnorg/portage-ample -root@chroot:~# emaint sync -r portage-ample +sh# eselect repository add portage-ample git https://git.bijl.us/lnorg/portage-ample +sh# emaint sync -r portage-ample ``` Then before emerging add the `dracut` flag for zlevis: @@ -290,13 +292,13 @@ app-crypt/zlevis dracut Then simply install it: ``` shell-session -root@chroot:~# emerge -av app-crypt/zlevis +sh# emerge -av app-crypt/zlevis ``` Now add `zlevis` to the pool with ``` shell-session -root@chroot:~# zfs set tpm:jwe=$(zlevis-encrypt '{}' < /tmp/rpool.key) rpool +sh# zfs set tpm:jwe=$(zlevis-encrypt '{}' < /tmp/rpool.key) rpool ``` ### UKI's @@ -348,7 +350,7 @@ rw root=ZFS=rpool/root/gentoo quiet splash Then finally install the packages mentioned which are required for a running system: ``` shell-session -root@chroot:~# emerge -av sbsigntools systemd-utils linux-firmware gentoo-kernel-bin zfs-kmod +sh# emerge -av sbsigntools systemd-utils linux-firmware gentoo-kernel-bin zfs-kmod ``` > Note that `gentoo-kernel-bin` was installed which is the pre-compiled Gentoo kernel. Later on we will compile our own custom kernel. @@ -358,7 +360,7 @@ It should have done this without throwing any errors. Because Gentoo generates UKI's for all the kernels installed on a system it would be nice to be able to choose upon boot which one. For a nice boot interface install `systemd-boot` on the ESP: ``` shell-session -root@chroot:~# bootctl install +sh# bootctl install Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi.signed" to "/efi/EFI/systemd/systemd-bootx64.efi". Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi.signed" to "/efi/EFI/BOOT/BOOTX64.EFI". Random seed file /efi/loader/random-seed successfully refreshed (32 bytes). @@ -368,14 +370,14 @@ Created EFI boot entry "Linux Boot Manager". The last thing to do is adding a few ZFS services on boot: ``` shell-session -root@chroot:~# rc-update add zfs-import sysinit -root@chroot:~# rc-update add zfs-mount sysinit +sh# rc-update add zfs-import sysinit +sh# rc-update add zfs-mount sysinit ``` Now exit the chroot and unmount the filesystem with: ``` shell-session -root@host:~# umount -lf /mnt +sh# umount -lf /mnt ``` The system should be functional after a reboot! diff --git a/docs/gentoo-desktop-setup/post-install/ccache.md b/docs/gentoo-desktop-setup/post-install/ccache.md index bfa036b..1b2f24c 100644 --- a/docs/gentoo-desktop-setup/post-install/ccache.md +++ b/docs/gentoo-desktop-setup/post-install/ccache.md @@ -1,7 +1,7 @@ `ccache` is a program which can save compiling cache, speeding up recompile's of big software. First install it: ``` shell-session -root@host:~# emerge -av dev-util/ccache +sh# emerge -av dev-util/ccache ``` And create a configuration file for `ccache`. diff --git a/docs/gentoo-desktop-setup/post-install/users.md b/docs/gentoo-desktop-setup/post-install/users.md index ac7cff5..220ee5d 100644 --- a/docs/gentoo-desktop-setup/post-install/users.md +++ b/docs/gentoo-desktop-setup/post-install/users.md @@ -1,8 +1,8 @@ Adding a user to the system is essential for actually using it as a desktop. It is pretty straight forward: ``` shell-session -root@host:~# useradd -m -G plugdev,pipewire -s /bin/bash -root@host:~# passwd +sh# useradd -m -G plugdev,pipewire -s /bin/bash +sh# passwd ... passwd: password updated successfully ``` @@ -22,7 +22,7 @@ app-admin/doas persist > This USE flag is necessary when typing the user's password every few seconds gets to annoying. ``` shell-session -root@host:~# emerge -av doas +sh# emerge -av doas ``` ``` title="/etc/doas.conf" diff --git a/docs/gentoo-desktop-setup/provisioning.md b/docs/gentoo-desktop-setup/provisioning.md index f5d3a0a..7a4d7a1 100644 --- a/docs/gentoo-desktop-setup/provisioning.md +++ b/docs/gentoo-desktop-setup/provisioning.md @@ -14,40 +14,40 @@ sh# setup-apkrepos -c1 A few packages will have to be installed first, ``` shell-session -root@host:~# apk add zfs lsblk sgdisk wipefs dosfstools +sh# apk add zfs lsblk sgdisk wipefs dosfstools ``` and load the ZFS kernel module ``` shell-session -root@host:~# modprobe zfs +sh# modprobe zfs ``` Wipe the existing disk partitions ``` shell-session -root@host:~# zpool labelclear -f /dev/ -root@host:~# wipefs -a /dev/ -root@host:~# sgdisk --zap-all /dev/ +sh# zpool labelclear -f /dev/ +sh# wipefs -a /dev/ +sh# sgdisk --zap-all /dev/ ``` Create on the disk an `EFI system` partition (ESP) and a `Linux filesystem` partition ``` shell-session -root@host:~# sgdisk -n 1:1m:+512m -t 1:ef00 /dev/ -root@host:~# sgdisk -n 2:0:-10m -t 2:8300 /dev/ +sh# sgdisk -n 1:1m:+512m -t 1:ef00 /dev/ +sh# sgdisk -n 2:0:-10m -t 2:8300 /dev/ ``` Reload the device nodes ``` shell-session -root@host:~# mdev -s +sh# mdev -s ``` Then, format the ESP with a FAT32 filesystem ``` shell-session -root@host:~# mkfs.fat -F 32 -n esp /dev/1 +sh# mkfs.fat -F 32 -n esp /dev/1 ``` ## ZFS pool creation @@ -55,7 +55,7 @@ root@host:~# mkfs.fat -F 32 -n esp /dev/1 The ZFS system pool is going to be encrypted. First generate an encryption key and save it temporarily to the file `/tmp/rpool.key` with: ``` shell-session -root@host:~# cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1 > /tmp/rpool.key && cat /tmp/rpool.key +sh# cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1 > /tmp/rpool.key && cat /tmp/rpool.key ``` > Later on in the guide `zlevis` will be used for automatic decryption, so this key only has to be entered a few times. However, if any changes are made to the bios or secureboot then this key will be needed again, so make sure to save it. @@ -63,7 +63,7 @@ root@host:~# cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1 > /t Create the system pool: ``` shell-session -root@host:~# zpool create -f \ +sh# zpool create -f \ -o ashift=12 \ -O compression=lz4 \ -O acltype=posix \ @@ -79,11 +79,14 @@ root@host:~# zpool create -f \ Then create the system datasets: ``` shell-session -root@host:~# zfs create -o mountpoint=none rpool/root -root@host:~# zfs create -o mountpoint=legacy -o quota=48g rpool/root/gentoo -root@host:~# zfs create -o mountpoint=legacy -o quota=32g rpool/root/gentoo/var -root@host:~# zfs create -o mountpoint=/home -o atime=off -o setuid=off -o devices=off -o quota= rpool/home +sh# zfs create -o mountpoint=none rpool/root +sh# zfs create -o mountpoint=legacy -o quota=48g rpool/root/gentoo +sh# zfs create -o mountpoint=legacy -o quota=32g rpool/root/gentoo/var +sh# zfs create -o mountpoint=/home -o atime=off -o setuid=off -o devices=off -o quota= rpool/home ``` > Setting the `` depends on the total size of the pool, generally try to reserve some empty space in the pool. +``` shell-session +sh# zpool export rpool +```