Changed formatting a bit again

This commit is contained in:
nils 2025-01-12 18:25:25 +01:00
parent ad89e9d364
commit f2b430287a
2 changed files with 59 additions and 60 deletions

View file

@ -3,25 +3,24 @@ Now is the time to actually install Gentoo.
First import the pool again:
``` shell-session
root # zpool import -N -R /mnt rpool
root # zfs load-key -L file:///tmp/rpool.key rpool
root@host:~# zpool import -N -R /mnt rpool
root@host:~# zfs load-key -L file:///tmp/rpool.key rpool
```
Then mount the datasets and the ESP on `/mnt`:
``` shell-session
root # mount -t zfs rpool/root/gentoo /mnt
root # mkdir /mnt/var
root # mount -t zfs rpool/root/gentoo/var /mnt/var
root # mkdir /mnt/efi
root # mount -t vfat /dev/disk/by-label/esp /mnt/efi
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
```
Now we're going to fetch a stage3 tarball for on the root of the system. Replace the `<release_date>` with the latest tarball release.
``` shell-session
root # cd /mnt
root # wget https://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-musl-hardened/stage3-amd64-musl-hardened-<release_date>.tar.xz
root@host:~# wget https://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64-musl-hardened/stage3-amd64-musl-hardened-<release_date>.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 <https://www.gentoo.org/downloads/mirrors/> for other mirrors.
@ -31,16 +30,16 @@ This should have placed a tarball at `/mnt/stage3-amd64-musl-hardened-*-.tar.xz`
Unpack it in the new root:
``` shell-session
root # tar xpvf stage3-*.tar.xz --numeric-owner -C /mnt
root@host:~# 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 # cp /etc/resolv.conf /mnt/etc/.
root # cp /tmp/rpool.key /mnt/tmp
root # for i in dev proc sys run; do mount --rbind --make-rslave /$i /mnt/$i; done
root # chroot /mnt
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
```
## Configuring the system
@ -100,11 +99,11 @@ MODULES_SIGN_HASH="sha512"
Now finally sync the repositories and try installing a package like `vim`.
``` shell-session
root # emaint sync
root@chroot:~# emaint sync
...
Action: sync for repo: gentoo, returned code = 0
root # emerge --ask --verbose app-editors/vim
root@chroot:~# emerge --ask --verbose app-editors/vim
>>> Completed (3 of 4) app-editors/vim-*::gentoo
```
@ -128,7 +127,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 # emerge -av sys-libs/timezone-data
root@chroot:~# emerge -av sys-libs/timezone-data
```
Select the correct timezone with:
@ -140,15 +139,15 @@ TZ="/usr/share/zoneinfo/<region>/<city>"
Update the environment of your shell-session:
``` shell-session
root # env-update && source /etc/profile
root@chroot:~# 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 # emerge -av net-misc/openntpd
root # rc-update add ntpd default
root # rc-service ntpd start
root@chroot:~# emerge -av net-misc/openntpd
root@chroot:~# rc-update add ntpd default
root@chroot:~# rc-service ntpd start
```
### Set up locales
@ -156,7 +155,7 @@ root # rc-service ntpd start
Musl also does not support locales out of the box. They aren't necessary but some programms rely on them to set the language of their application. To be able to use locales install the `musl-locales` package:
``` shell-session
root # emerge -av sys-apps/musl-locales
root@chroot:~# emerge -av sys-apps/musl-locales
```
And to allow the system to know where the locales are located:
@ -168,9 +167,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 diverent one should not break the system. Choose the desired locale with $n \in \mathbb{N}$:
``` shell-session
root # eselect locale list
root # eselect locale set <n>
root # env-update && source /etc/profile
root@chroot:~# eselect locale list
root@chroot:~# eselect locale set <n>
root@chroot:~# env-update && source /etc/profile
```
### Setting the hostname
@ -178,7 +177,7 @@ root # 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 <hostname> with the desired name:
``` shell-session
root # echo "<hostname>" > /etc/hostname
root@chroot:~# echo "<hostname>" > /etc/hostname
```
### Internet
@ -192,13 +191,13 @@ net-misc/networkmanager dhcpcd -wext -modemmanager -ppp
Also make sure the `networkmanager` USE flag is enabled in your `make.conf`. Then emerge `networkmananger`:
``` shell-session
root # emerge -av net-misc/networkmanager
root@chroot:~# emerge -av net-misc/networkmanager
```
Then disable any other network services before enabling the `NetworkManager`service:
``` shell-session
root # rc-update add NetworkManager default
root@chroot:~# rc-update add NetworkManager default
* service NetworkManager added to runlevel default
```
@ -207,9 +206,9 @@ root # 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 # emerge -av app-eselect/eselect-repository
root # eselect repository enable guru
root # emaint sync --repo guru
root@chroot:~# emerge -av app-eselect/eselect-repository
root@chroot:~# eselect repository enable guru
root@chroot:~# emaint sync --repo guru
```
To allow unstable packages from GURU set the `~amd64` keyword for it:
@ -225,7 +224,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 # emerge -av sbctl
root@chroot:~# emerge -av sbctl
```
> Verify that Secureboot mode is on and in setup mode with `sbctl status`
@ -233,12 +232,12 @@ root # emerge -av sbctl
Then create and enroll keys into the system.
``` shell-session
root # sbctl create-keys
root@chroot:~# sbctl create-keys
Created Owner UUID abcde....
Creating secure boot keys...✔
Secure boot keys created!
root # sbctl enroll-keys <--microsoft>
root@chroot:~# sbctl enroll-keys <--microsoft>
...
Enrolled keys to the EFI variables!
```
@ -250,8 +249,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 # eselect repository add portage-ample git https://git.bijl.us/lnorg/portage-ample
root # emaint sync -r portage-ample
root@chroot:~# eselect repository add portage-ample git https://git.bijl.us/lnorg/portage-ample
root@chroot:~# emaint sync -r portage-ample
```
Then before emerging add the `dracut` flag for zlevis:
@ -263,13 +262,13 @@ app-crypt/zlevis dracut
Then simply install it:
``` shell-session
root # emerge -av app-crypt/zlevis
root@chroot:~# emerge -av app-crypt/zlevis
```
Now add `zlevis` to the pool with
``` shell-session
root # zfs set tpm:jwe=$(zlevis-encrypt '{}' < /tmp/rpool.key) rpool
root@chroot:~# zfs set tpm:jwe=$(zlevis-encrypt '{}' < /tmp/rpool.key) rpool
```
### UKI's
@ -321,7 +320,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 # emerge -av sbsigntools systemd-utils linux-firmware gentoo-kernel-bin zfs-kmod
root@chroot:~# 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.
@ -331,7 +330,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 # bootctl install
root@chroot:~# 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).
@ -341,14 +340,14 @@ Created EFI boot entry "Linux Boot Manager".
The last thing to do is adding a few ZFS services on boot:
``` shell-session
root # rc-update add zfs-import sysinit
root # rc-update add zfs-mount sysinit
root@chroot:~# rc-update add zfs-import sysinit
root@chroot:~# rc-update add zfs-mount sysinit
```
Now exit the chroot and unmount the filesystem with:
``` shell-session
root # umount -lf /mnt
root@chroot:~# umount -lf /mnt
```
The system should be functionalafter reboot!

View file

@ -5,8 +5,8 @@ After booting the Alpine Linux extended ISO, partition the disks. For this actio
To set it up `setup-interfaces` and `setup-apkrepos` will be used.
``` shell-session
root # setup-interfaces -ar
root # setup-apkrepos -c1
root@host:~# setup-interfaces -ar
root@host:~# setup-apkrepos -c1
```
> To use Wi-Fi simply run `setup-interfaces -r` and select `wlan0` or similar.
@ -14,40 +14,40 @@ root # setup-apkrepos -c1
A few packages will have to be installed first,
``` shell-session
root # apk add zfs lsblk sgdisk wipefs dosfstools
root@host:~# apk add zfs lsblk sgdisk wipefs dosfstools
```
and load the ZFS kernel module
``` shell-session
root # modprobe zfs
root@host:~# modprobe zfs
```
Wipe the existing disk partitions
``` shell-session
root # zpool labelclear -f /dev/<disk>
root # wipefs -a /dev/<disk>
root # sgdisk --zap-all /dev/<disk>
root@host:~# zpool labelclear -f /dev/<disk>
root@host:~# wipefs -a /dev/<disk>
root@host:~# sgdisk --zap-all /dev/<disk>
```
Create on the disk an `EFI system` partition (ESP) and a `Linux filesystem` partition
``` shell-session
root # sgdisk -n 1:1m:+512m -t 1:ef00 /dev/<disk>
root # sgdisk -n 2:0:-10m -t 2:8300 /dev/<disk>
root@host:~# sgdisk -n 1:1m:+512m -t 1:ef00 /dev/<disk>
root@host:~# sgdisk -n 2:0:-10m -t 2:8300 /dev/<disk>
```
Reload the device nodes
``` shell-session
root # mdev -s
root@host:~# mdev -s
```
Then, format the ESP with a FAT32 filesystem
``` shell-session
root # mkfs.fat -F 32 -n esp /dev/<disk>1
root@host:~# mkfs.fat -F 32 -n esp /dev/<disk>1
```
## ZFS pool creation
@ -55,7 +55,7 @@ root # mkfs.fat -F 32 -n esp /dev/<disk>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 # cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1 > /tmp/rpool.key && cat /tmp/rpool.key
root@host:~# 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 # cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1 > /tmp/rpo
Create the system pool:
``` shell-session
root # zpool create -f \
root@host:~# zpool create -f \
-o ashift=12 \
-O compression=lz4 \
-O acltype=posix \
@ -79,10 +79,10 @@ root # zpool create -f \
Then create the system datasets:
``` shell-session
root # zfs create -o mountpoint=none rpool/root
root # zfs create -o mountpoint=legacy -o quota=48g rpool/root/gentoo
root # zfs create -o mountpoint=legacy -o quota=32g rpool/root/gentoo/var
root # zfs create -o mountpoint=/home -o atime=off -o setuid=off -o devices=off -o quota=<home-quota> rpool/home
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=<home-quota> rpool/home
```
> Setting the `<home-quota>` depends on the total size of the pool, generally try to reserve some empty space in the pool.