documentation/docs/alpine-desktop-setup/installation.md

172 lines
5.1 KiB
Markdown
Raw Normal View History

# Installation
To install the Alpine Linux distribution on the system, the encrypted partition and the efi partition have to be mounted to the main system.
```
2023-12-27 14:15:07 +01:00
# mount /dev/vg<m>/root<n> /mnt -t ext4
# mkdir /mnt/boot/efi -p
2023-12-26 12:53:07 +01:00
# mount /dev/<disk1> /mnt/boot/efi -t vfat
```
Then set up the base system using `setup-disk`:
```
# setup-disk -m sys /mnt
```
This will also add grub as bootloader which is going to be replaced on this system but for now it will reside on the boot partition.
Now the other directories are going to be mounted so that it's possible to chroot into the system:
```
# for i in dev proc sys run; do
> mount --rbind --make-rslave /$i /mnt/$i
> done
2023-12-27 14:15:07 +01:00
# mount /dev/vg<m>/var<n> /mnt/var
# mount /dev/vg<m>/tmp<n> /mnt/tmp
# chroot /mnt
```
The other "setup" scripts can be used to configure key aspects of the system.
```
# setup-hostname <hostname>
# setup-keymap us us-euro
# 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
# passwd root
```
2023-12-27 13:52:44 +01:00
Set the `hwclock` to use `localtime` instead of `UTC` in `/etc/conf.d/hwclock`:
2023-12-26 12:53:07 +01:00
```
clock="local"
clock_hctosys="NO"
clock_systohc="NO"
```
2023-12-27 13:52:44 +01:00
Edit `/etc/fstab` for correct mounts:
```
2023-12-29 15:42:12 +01:00
/dev/disk/by-label/efi /boot/efi vfat defaults,nodev,nosuid,noexec 0 2
2023-12-27 14:15:07 +01:00
/dev/vg<m>/root<n> / ext4 defaults,noatime 0 1
2023-12-29 15:42:12 +01:00
/dev/vg<m>/home<n> /home ext4 defaults,noatime,nosuid,nodev 0 1
2023-12-27 14:15:07 +01:00
/dev/vg<m>/tmp<n> /tmp ext4 defaults,nodev,nosuid,noexec 0 1
/dev/vg<m>/var<n> /var ext4 defaults,nodev,nosuid,noexec 0 1
2023-12-29 15:42:12 +01:00
/dev/vg<m>/nix<n> /nix ext4 defaults,noatime,nodev,nosuid 0 1
2023-12-27 12:25:14 +01:00
proc /proc proc nosuid,nodev,noexec,hidepid=2 0 0
```
2023-12-27 13:52:44 +01:00
By default Alpine Linux uses `mkinitfs` to create initramfs, although it is minimal that also means that it lacks some functionality which is needed for a proper setup. Because of this `mkinitfs` and `grub-efi `will be replaced with `booster` and `secureboot-hook`.
```
# apk add booster secureboot-hook sbctl
# apk del mkinitfs grub-efi
```
To configure booster edit `/etc/booster.yaml`:
```
2023-12-26 12:53:07 +01:00
busybox: false
modules: vfat,nls_cp437,nls_iso8859_1
enable_lvm: true
```
2023-12-26 13:24:37 +01:00
The most important step is the creation of uki's using `secureboot-hook` which also automatically signs them. First the hook itself will have to be tweaked to use `booster` instead of `mkinitfs`, edit `/etc/kernel-hooks.d/50-secureboot.hook` and change the line:
```
/sbin/mkinitfs -o "$tmpdir"/initramfs "$NEW_VERSION-$FLAVOR"
```
To:
```
/usr/bin/booster build "$tmpdir"/initramfs --kernel-version "$NEW_VERSION-$FLAVOR"
```
2023-12-26 12:58:01 +01:00
And configure `/etc/kernel-hooks.d/secureboot.conf` for cmdline and secureboot.
```
2023-12-27 14:15:07 +01:00
cmdline="rw rd.luks.name=<uuid>=luks root=/dev/vg<m>/root<n> modules=ext4 quiet splash rd.lvm.vg=vg<m>"
signing_cert="/usr/share/secureboot/keys/db/db.pem"
signing_key="/usr/share/secureboot/keys/db/db.key"
output_dir="/boot/efi/EFI/Linux"
output_name="alpine-linux-{flavor}.efi"
```
Here `<uuid>` has to be replaced with the uuid of the partition which contains our volume group:
```
2023-12-27 12:08:59 +01:00
# blkid /dev/<disk2> >> /etc/kernel-hooks.d/secureboot.conf
```
All that's left for booting is secureboot which `sbctl` will be used for to create keys, and sign some executables with.
```
# 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.
Now to see if everything went succesfully run:
```
# apk fix kernel-hooks
```
And it should give no warnings if done properly.
To make our lives easier we'll also install `gummiboot` as a bootloader.
```
# apk add gummiboot
2023-12-24 13:08:54 +01:00
# gummiboot install --path=/boot/efi
# sbctl sign -s /boot/efi/EFI/gummiboot/gummibootx64.efi
2023-12-24 13:11:24 +01:00
# sbctl sign -s /boot/efi/EFI/Boot/BOOTX64.EFI
```
And also remove some junk left over by grub.
```
# rm -rf /boot/efi/EFI/alpine
2023-12-24 01:46:48 +01:00
# rm -rf /boot/grub
2023-12-26 12:58:01 +01:00
# unlink /boot/boot
```
2023-12-27 15:33:56 +01:00
You can also install `os-prober` which can find operating systems and add them to your bootloader. Besides that `gummiboot` can also be configured with the file `/boot/efi/loader/loader.conf` in which you can specify the timeout and what OS it should load into by default.
```
default alpine
2023-12-27 15:49:24 +01:00
timeout 2
2023-12-27 15:33:56 +01:00
editor no
```
2023-12-26 12:53:07 +01:00
Before finishing up the installation `networkmanager` will be installed for networking.
```
# apk add networkmanager
# setup-devd udev
# rc-update add networkmanager default
```
Wifi will not yet work but this is will be done later on.
2023-12-26 13:24:37 +01:00
> If internet doesn't work after reboot follow the instructions in the [network section](https://docs.bijl.us/alpine-desktop-setup/post-install/network/).
Now exit out of the chroot and you should be able to reboot into a working Alpine system.
```
# exit
# umount -lf /mnt
2023-12-24 01:10:15 +01:00
# reboot
```
> Do note that "Linux Boot Manager" will have to be set to load first in your bios.
2023-12-24 01:46:48 +01:00
> When booting up your screen might appear blank but you will have to enter the password you added for encryption and press enter.