First up....
This Alpine Wiki article and the pastebin document found under "Discussions" got me to a working state but I wanted to put my own slightly clearer version out there.
Also the Arch wiki entry on ZFS root was super helpful for the ZFS system datasets.
Don't type comments. Comments are anything between #
and the end of the line.
- Install required packages:
apk add zfs parted e2fsprogs syslinux
- Alpine setup:
setup-alpine # and Ctrl-C when you get to disk setup
- Partition:
parted /dev/sdX (parted) mklabel msdos # answer yes (parted) mkpart primary ext4 1M 200M # I like 200M but you can use 100M just fine (parted) set 1 boot on # pretty self explanatory (parted) mkpart primary 201M 100%
- Create Filesystems:
mdev -s # create device nodes mkfs.ext4 /dev/sdX1 modprobe zfs zpool create -f -o ashift=12 \ -O acltype=posixacl -O canmount=off -O compression=lz4 \ -O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa \ -O encryption=aes-256-gcm -O keylocation=prompt -O keyformat=passphrase \ -O mountpoint=/ -R /mnt \ rpool /dev/sdX2
- Get ready to run the setup:
zfs create -o mountpoint=none -o canmount=off rpool/ROOT zfs create -o mountpoint=legacy rpool/ROOT/alpine # will get mounted to / mount -t zfs rpool/ROOT/rpool /mnt/ zfs create -o mountpoint=/var rpool/var zfs create -o mountpoint=/var/log rpool/var/log zfs create -o mountpoint=/var/lib rpool/var/lib # ... and so on zfs create -o mountpoint=none rpool/data zfs create -o mountpoint=/home rpool/data/home zfs create -o mountpoint=/root rpool/data/home/root mkdir /mnt/boot/ mount -t ext4 /dev/sdX1 /mnt/boot/ rc-update add zfs-import sysinit rc-update add zfs-mount sysinit
- Alpine setup (2/2):
setup-disk /mnt
- boot from image
- install and activate zfs
apk add zfs modprobe zfs
- import the pool to
/mnt
without mounting:zpool import -NR /mnt rpool
- unlock the datasets:
zfs load-key rpool
- mount the root dataset:
mount -t zfs rpool/ROOT/alpine /mnt
- mount the rest:
zfs mount -a
- don't forget boot: `mount -t ext4 /dev/sda1 /mnt/boot
- set up the chroot:
- as far as I can tell, the following special filesystems are required for rebuilding
syslinux
-
mount -o bind /dev /mnt/dev
-
mount -t proc none /mnt/proc
-
mount -o bind /sys /mnt/sys
-
- as far as I can tell, the following special filesystems are required for rebuilding
- chroot:
chroot /mnt
- rebuild the bootloader:
extlinux --install /boot
- replace the MBR:
dd if=/usr/share/syslinux/mbr.bin of=/dev/sda
- you may
exit
andpoweroff