documentation/docs/alpine-desktop-setup/provisioning.md
2024-10-27 12:04:30 +01:00

2.5 KiB

Provisioning

After flasing the Alpine Linux extended ISO, partition a disk. For this action internet is required since gptfdisk is not included on the extended ISO, therefore it needs to be obtained from the repository.

To set it up setup-interfaces and setup-apkrepos will be used.

# setup-interfaces -ar
# setup-apkrepos -c1

To use wifi simply run setup-interfaces -r and select wlan0 or similar.

A few packages will have to be installed first:

# apk add zfs lsblk sgdisk wipefs dosfstools acpid 

and load the ZFS kernel module

# modprobe zfs

Wipe the existing disk partitions

# zpool labelclear -f /dev/<disk>
# wipefs -a /dev/<disk>
# sgdisk --zap-all /dev/<disk>

Create on the disk an EFI system partition (ESP) and a Linux filesystem partition

# sgdisk -n 1:1m:+512m -t 1:ef00 /dev/<disk>
# sgdisk -n 2:0:-10m -t 2:8300 /dev/<disk>

Reload the device nodes

# mdev -s

Then, format the ESP with a FAT32 filesystem

# mkfs.fat -F 32 -n esp /dev/<disk>1

ZFS pool creation

The ZFS system pool is going to be encrypted. First generate an encryption key and save it temporarily to the file /tmp/tank.key with:

# cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1 > /tmp/tank.key && cat /tmp/tank.key

Later on in the guide clevis 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 write it down.

Create the system pool:

# zpool create -f \
    -o ashift=12 \
    -O canmount=off \
    -O compression=lz4 \
    -O acltype=posix \ 
    -O xattr=sa \
    -O dnodesize=auto \
    -O atime=off \
    -O normalization=formD \
    -O encryption=on \
    -O keyformat=passphrase \
    -O keylocation=prompt \
    -m none \
    tank /dev/<disk2>

Then create the system datasets:

# zfs create -o mountpoint=none tank/root
# zfs create -o mountpoint=legacy -o quota=24g tank/root/alpine
# zfs create -o mountpoint=/home -o setuid=off -o devices=off -o quota=<home-quota> tank/home
# zfs create -o mountpoint=/var -o exec=off -o setuid=off -o devices=off -o quota=16g tank/var

Setting the <home-quota> depends on the total size of the pool, generally try to reserve some empty space in the pool.

Finally, export the zpool:

# zpool export tank