2023-12-24 00:38:47 +01:00
# Installation
2024-10-27 12:04:30 +01:00
To install the Alpine Linux distribution on the system, the datasets of the system pool and the EFI partitions have to be mounted to the main system.
First import and decrypt the system pool.
```
# zpool import -N -R /mnt tank
# zfs load-key tank
```
Mount the datasets in the system pool and decrypt the home dataset.
```
# mount tank/root/alpine /mnt -t zfs -o noatime
# zfs mount tank/home
# zfs mount tank/var
```
Mount the ESP.
2023-12-24 00:38:47 +01:00
```
2024-08-31 12:53:55 +02:00
# mkdir /mnt/esp
# mount /dev/disk/by-label/esp /mnt/esp -t vfat
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
Then install Alpine Linux.
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
# export BOOTLOADER=none
2023-12-24 00:38:47 +01:00
# setup-disk -m sys /mnt
```
2024-10-27 12:04:30 +01:00
To have a functional chroot into the system, bind the system process directories.
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
# for dir in dev proc sys run; do
> mount --rbind --make-rslave /$dir /mnt/$dir
2023-12-24 00:38:47 +01:00
> done
# chroot /mnt
```
2024-03-24 17:37:18 +01:00
The other setup scripts can be used to configure key aspects of the system. Besides that a few necessary services have to be activated.
2023-12-24 00:38:47 +01:00
```
# setup-hostname <hostname>
# setup-keymap us us-euro
2023-12-27 12:06:05 +01:00
# setup-timezone -i <area>/<subarea>
2023-12-24 02:33:57 +01:00
# setup-ntp openntpd
2023-12-24 02:15:39 +01:00
# rc-update add acpid default
2024-03-24 17:37:18 +01:00
# rc-update add seedrng boot
2024-08-31 12:53:55 +02:00
# rm -rf /var/tmp
# ln -s /tmp /var/tmp
2023-12-24 00:38:47 +01:00
# passwd root
```
2024-01-03 21:02:59 +01:00
> The root password does not really matter because it is going to be locked after a user has been created.
2023-12-30 01:19:33 +01:00
2024-06-05 10:32:46 +02:00
Set the `hwclock` to use `UTC` in `/etc/conf.d/hwclock` and disable writing the time to hardware. Running a NTP negates its usability.
2023-12-26 12:53:07 +01:00
```
2024-06-05 10:32:46 +02:00
clock="UTC"
2023-12-26 12:53:07 +01:00
clock_hctosys="NO"
clock_systohc="NO"
```
2024-10-27 12:04:30 +01:00
Configure the ESP raid array to mount.
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
# modprobe raid1
# echo raid1 >> /etc/modules-load.d/raid1.conf
# mdadm --detail --scan >> /etc/mdadm.conf
# rc-update add mdadm boot
# rc-update add mdadm-raid boot
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
Configure ZFS to mount.
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
rc-update add zfs-import sysinit
rc-update add zfs-mount sysinit
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
Edit `/etc/fstab` for correct mounts:
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
tank/root/alpine / zfs rw,noatime,xattr,posixacl,casesensitive 0 1
/dev/md/esp /esp vfat defaults,nodev,nosuid,noexec 0 2
tmpfs /tmp tmpfs rw,nodev,nosuid,noexec,mode=1777 0 0
proc /proc proc nodev,nosuid,noexec,hidepid=2 0 0
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
By default, Alpine Linux uses `mkinitfs` to create an initial ram filesystem.
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
# apk add secureboot-hook sbctl
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
Configure `/etc/mkinitfs/mkinitfs.conf` to disable it's hook:
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
# echo 'disable_trigger=yes' >> /etc/mkinitfs/mkinitfs.conf
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
The most important step is the creation of a UKI using `secureboot-hook` which also automatically signs them. Configure `/etc/kernel-hooks.d/secureboot.conf` for cmdline and secureboot.
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
cmdline="rw root=ZFS=tank/root/alpine quiet splash"
2023-12-24 00:38:47 +01:00
signing_cert="/usr/share/secureboot/keys/db/db.pem"
signing_key="/usr/share/secureboot/keys/db/db.key"
2024-08-31 12:53:55 +02:00
output_dir="/esp/efi/linux"
2023-12-24 00:38:47 +01:00
output_name="alpine-linux-{flavor}.efi"
```
2024-01-03 21:02:59 +01:00
Use `sbctl` to create secureboot keys and sign them.
2023-12-24 00:38:47 +01:00
```
# sbctl create-keys
# sbctl enroll-keys
```
2023-12-24 13:08:54 +01:00
> Whilst enrolling the keys it might be necessary to add the `--microsoft` flag if you are unable to use custom keys.
2023-12-24 00:38:47 +01:00
2024-10-27 12:04:30 +01:00
Set the cache-file of the ZFS pool.
```
# zpool set cachefile=/etc/zfs/zpool.cache tank
```
Now to see if everything went successfully, run:
2023-12-24 00:38:47 +01:00
```
# apk fix kernel-hooks
```
2024-08-31 12:53:55 +02:00
and it should give no warnings if done properly.
2023-12-24 00:38:47 +01:00
2024-10-27 12:04:30 +01:00
To install `gummiboot` as friendly bootloader:
2023-12-24 00:38:47 +01:00
```
# apk add gummiboot
2024-08-31 12:53:55 +02:00
# mkdir /esp/loader
# mkdir /esp/efi/boot
# cp /usr/lib/gummiboot/gummibootx64.efi /esp/efi/boot/bootx64.efi
```
2024-10-27 12:04:30 +01:00
Sign the bootloader with `sbctl` .
2024-08-31 12:53:55 +02:00
```
# sbctl sign -s /esp/efi/boot/bootx64.efi
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
> One may verify the signed files by running `sbctl verify`, in this case `ESP_PATH=/esp` should be defined to work properly.
`gummiboot` can be configured with the file `/esp/loader/loader.conf` with which the timeout and the default OS can be specified.
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
default alpine-linux-lts.efi
timeout 5
editor no
2023-12-24 00:38:47 +01:00
```
2024-10-27 12:04:30 +01:00
> Here, there should be lines explaining the setup of automatic decryption with TPM using Clevis. Which is still in development...
2023-12-27 15:33:56 +01:00
```
2024-10-27 12:04:30 +01:00
# clevis encrypt tpm2 '{}' << ''
2023-12-27 15:33:56 +01:00
```
2023-12-26 12:53:07 +01:00
2024-08-31 12:53:55 +02:00
Before finishing the installation `networkmanager` will be installed for networking. Also install `networkmanager-wifi` and `wpa_supplicant` for Wi-Fi functionality.
2023-12-26 12:53:07 +01:00
```
2024-04-24 12:02:58 +02:00
# apk add networkmanager networkmanager-wifi wpa_supplicant
2023-12-26 12:53:07 +01:00
# setup-devd udev
# rc-update add networkmanager default
```
2024-10-27 12:04:30 +01:00
Wi-Fi will not yet work. For Wi-Fi configuration see the network section.
2023-12-26 12:53:07 +01:00
2024-10-27 12:04:30 +01:00
> If internet does not work after reboot create the config file as described in the network section and restart the service.
2023-12-26 13:24:37 +01:00
2024-01-03 21:02:59 +01:00
Now exit the chroot and you should be able to reboot into a working Alpine system.
2023-12-24 00:38:47 +01:00
```
# exit
# umount -lf /mnt
2024-10-27 12:04:30 +01:00
# zpool export tank
2023-12-24 01:10:15 +01:00
# reboot
2023-12-24 00:38:47 +01:00
```