https://ramsdenj.com/2016/06/23/arch-linux-on-zfs-part-2-installation.html#pre-install-setup
https://aaronlauterer.com/blog/2017/04/arch-linux-on-an-encrypted-zfs-root-system/
https://help.ubuntu.com/community/encryptedZfs
ZFS raid made easy: https://www.maketecheasier.com/use-zfs-filesystem-ubuntu-linux/
When installing zfs-dkms and spl-dkms they are dependant on linux-headers.
If the linux package on the live iso is behind of the linux-headers package in the repos(which will be installed further down), the dkms effectively can not load the zfs and spl kernel modules against the one installed on the live iso whend doing: (further down) # modprobe zfs
Therefore make an up to date live iso which has the latest kernel installed following: https://wiki.archlinux.org/index.php/Archiso
# dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress && sync
# mount -o remount,size=6G /run/archiso/cowspace
# loadkeys be-latin1
# wifi-menu
# vim /etc/pacman.conf
----------------------
[archzfs]
Server = http://archzfs.com/$repo/$arch
# pacman-key -r 0ee7a126
# pacman-key --lsign-key 0ee7a126
# pacman-key -r F75D9D76
# pacman-key --lsign-key F75D9D76
# pacman -Sy linux-headers zfs-dkms spl-dkms
# modprobe zfs
# touch /etc/zfs/zpool.cache
# parted /dev/sdx
-----------------
(parted) mklabel gpt
(parted) mkpart ESP fat32 1MiB 513MiB
(parted) set 1 boot on
(parted) mkpart primary ext2 513MiB 99%
# mkfs.vfat /dev/sdx1
# cryptsetup luksFormat --type luks2 -v -s 512 /dev/sdx2
# cryptsetup open /dev/sdx2 cryptroot
canmount=off
makes it so actual data is stored inside the parent dataset; but
the hierarchical structure exists for possible children.
Double check before you run any of these; not all are necessarily required either
# zpool create -o ashift=12 -o cachefile=/etc/zfs/zpool.cache -m none -R /mnt zroot /dev/mapper/cryptroot
# zfs create -o mountpoint=none -o compression=lz4 zroot/ROOT
# zfs create -o mountpoint=/ zroot/ROOT/default
# zfs create -o canmount=off -o mountpoint=/var -o xattr=sa zroot/ROOT/var
# zfs create -o canmount=off -o mountpoint=/var/lib zroot/ROOT/var/lib
# zfs create -o canmount=off -o mountpoint=/var/lib/systemd zroot/ROOT/var/lib/systemd
# zfs create -o canmount=off -o mountpoint=/usr zroot/ROOT/usr
# zfs create -o mountpoint=/opt zroot/ROOT/opt
# zfs create -o mountpoint=/var/lib/systemd/coredump zroot/ROOT/var/lib/systemd/coredump
# zfs create -o mountpoint=/var/log zroot/ROOT/var/log
# zfs create -o acltype=posixacl -o mountpoint=/var/log/journal zroot/ROOT/var/log/journal
# zfs create -o mountpoint=/home zroot/home
# zfs create -o mountpoint=/root zroot/home/root
# zfs create -o mountpoint=/home/<username> zroot/home/<username>
# zpool set bootfs=zroot zroot
# zfs set relatime=on zroot
# zfs set compression=lz4 zroot
# zfs create -V 16G -b 4096 -o logbias=throughput -o sync=always -o primarycache=metadata -o com.sun:auto-snapshot=false zroot/swap
# mkswap -f /dev/zvol/zroot/swap
# zpool export zroot
# zpool import -R /mnt zroot
# mkdir /mnt/boot
# mount /dev/sdx1 /mnt/boot
# pacstrap -i /mnt base base-devel
# loadkeys us
# genfstab -U -p /mnt | grep boot >> /mnt/etc/fstab
# loadkeys be-latin1
# vim /mnt/etc/fstab
--------------------
/dev/zvol/zroot/swap none swap discard 0 0
# arch-chroot /mnt /bin/bash
# vi /etc/locale.gen
--------------------
Uncomment en_US.UTF-8 UTF-8
# locale-gen
# vi /etc/locale.conf
---------------------
LANG=en_US.UTF-8
# rm /etc/localtime
# ln -s /usr/share/zoneinfo/Europe/Brussels /etc/localtime
# hwclock --systohc --utc
# pacman -S ntp
# ntpd -q
# hwclock -w
# pacman -S vim
# pacman -S terminus-font
# vim /etc/vconsole.conf
------------------------
KEYMAP=be-latin1
FONT=ter-112n
# vim /etc/pacman.conf
----------------------
[archzfs]
Server = http://archzfs.com/$repo/$arch
# pacman-key -r 0ee7a126
# pacman-key --lsign-key 0ee7a126
# vim /etc/pacman.d/mirrorlist
------------------------------
Move i3d.net up to top (with https)
# pacman -S reflector
# reflector --country Sweden --latest 200 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
# pacman -Syu
# pacman -S linux-headers zfs-dkms spl-dkms
# systemctl enable zfs.target
# systemctl enable zfs-import-cache
# systemctl enable zfs-mount
# vim /etc/modprobe.d/zfs.conf
------------------------------
options zfs zfs_arc_max="2147483648"
# vim /etc/mkinitcpio.conf
--------------------------
HOOKS=(base udev autodetect modconf keyboard keymap consolefont block encrypt zfs filesystems)
**NEEDS RESEARCHING:**
System finally booted after adding usr after zfs in HOOKS. \
Could be because repasted the UUID into /boot/loader/entries/arch.conf too.
# mkinitcpio -p linux
# passwd
# vim /etc/hostname
-------------------
<hostname>
# bootctl --path=/boot install
# vim /boot/loader/loader.conf
------------------------------
default arch
timeout 4
editor 0
# loadkeys us
# blkid /dev/sdx2 > partitionid.txt
# loadkeys be-latin1
# vim /boot/loader/entries/arch.conf
------------------------------------
title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options cryptdevice=UUID=<UUID>:cryptroot:allow-discards zfs=zroot/ROOT/default rw pcie_aspm=force
# vim /boot/loader/entries/arch-fallback.conf
---------------------------------------------
title Arch Linux Fallback
linux /vmlinuz-linux
initrd /initramfs-linux-fallback.img
options cryptdevice=UUID=<UUID>:cryptroot:allow-discards zfs=zroot/ROOT/default rw
# pacman -S networkmanager openssh tlp smartmontools ethtool networkmanager-openvpn x86_energy_perf_policy
# systemctl enable NetworkManager
# systemctl enable tlp
# systemctl enable tlp-sleep
# systemctl enable fstrim.timer
# vim /etc/modprobe.d/alsa-base.conf
------------------------------------
options snd_hda_intel index=1,0
# exit
# cp /etc/zfs/zpool.cache /mnt/etc/zfs/
# umount /mnt/boot
# zpool export zroot
# reboot
# nmcli d wifi list
# nmcli dev wifi connect <SSID> password <password>
# ping google.com
# pacman -S zsh
# useradd -m -G wheel -s /bin/zsh <username>
# zfs allow <username> create,mount,mountpoint,snapshot zroot/home/<username>
# chown -R <username> /home/<username>
# passwd <username>
# visudo
--------
Uncomment %wheel ALL=(ALL) ALL
# pacman -S rsync xorg-server xf86-video-intel xorg-xinit xorg-xrandr i3 pulseaudio pavucontrol termite conky git libyaml gcc6 imagemagick xorg-xbacklight mpv notify-osd ttf-inconsolata ttf-bitstream-vera ttf-dejavu ttf-droid ttf-fira-mono ttf-fira-sans ttf-freefont ttf-liberation ttf-roboto ttf-ubuntu-font-family
# exit
$ cp /etc/X11/xinit/xinitrc .xinitrc
$ vim .xinitrc
--------------
exec i3
$ gsettings set org.gnome.desktop.interface scaling-factor 2
$ vim .Xresources
-----------------
Xft.dpi: 166
Xft.autohint: false
Xft.hintstyle: hintslight
Xft.lcdfilter: lcddefault
Xft.hinting: true
Xft.antialias: true
Xft.rgba: rgb
$ startx
$ setxkbmap be