* Let user know that SELinux will be re-enabled after reboot Signed-off-by: Maurice Zhou <jasper@apvc.uk> * compat with future releases: use zfs-dkms and newer repo Signed-off-by: Maurice Zhou <jasper@apvc.uk> * rm unused releasever option Signed-off-by: Maurice Zhou <jasper@apvc.uk> * let user aware of the ignorable errors Signed-off-by: Maurice Zhou <jasper@apvc.uk> * detailed explanations for errors during grub-menu generation Signed-off-by: Maurice Zhou <jasper@apvc.uk> * Build ZFS dkms module in installed system Signed-off-by: Maurice Zhou <jasper@apvc.uk> * switch to dkms package for better compatibility with kernels Signed-off-by: Maurice Zhou <jasper@apvc.uk> * add direct download links for live iso Signed-off-by: Maurice Zhou <jasper@apvc.uk> * rm zfs-fuse before install; mirrorlist Signed-off-by: Maurice Zhou <jasper@apvc.uk> * reformat notes Signed-off-by: Maurice Zhou <jasper@apvc.uk> * rm netconfig - networkmanager is enabled by default Signed-off-by: Maurice Zhou <jasper@apvc.uk> * load kernel module in live; Signed-off-by: Maurice Zhou <jasper@apvc.uk> * rm encrypted bpool: untested Signed-off-by: Maurice Zhou <jasper@apvc.uk> * use u=r,go= permission on key file Signed-off-by: Maurice Zhou <jasper@apvc.uk> * fix typo Signed-off-by: Maurice Zhou <jasper@apvc.uk> * use bash shell Signed-off-by: Maurice Zhou <jasper@apvc.uk> * suggest clean the disks Signed-off-by: Maurice Zhou <jasper@apvc.uk> * add grub-menu auto update Signed-off-by: Maurice Zhou <jasper@apvc.uk> * monitor kernel-core pkg Signed-off-by: Maurice Zhou <jasper@apvc.uk> * copyright 2021 Signed-off-by: Maurice Zhou <jasper@apvc.uk> * fix kernel var detection Signed-off-by: Maurice Zhou <jasper@apvc.uk> * read-only cache file Signed-off-by: Maurice Zhou <jasper@apvc.uk> * replace zfs-mount.service with zfs-mount-generator Signed-off-by: Maurice Zhou <jasper@apvc.uk> * notes for mount and POSIX-compliant Signed-off-by: Maurice Zhou <jasper@apvc.uk> * hard-code kernel version Signed-off-by: Maurice Zhou <jasper@apvc.uk> * fix chroot variable Signed-off-by: Maurice Zhou <jasper@apvc.uk> * fix grub cfg Signed-off-by: Maurice Zhou <jasper@apvc.uk> * fix grub Signed-off-by: Maurice Zhou <jasper@apvc.uk> * missing comment Signed-off-by: Maurice Zhou <jasper@apvc.uk> * comments Signed-off-by: Maurice Zhou <jasper@apvc.uk>
169 lines
4.7 KiB
ReStructuredText
169 lines
4.7 KiB
ReStructuredText
.. highlight:: sh
|
|
|
|
Bootloader
|
|
======================
|
|
|
|
.. contents:: Table of Contents
|
|
:local:
|
|
|
|
Apply workarounds
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
Currently GRUB has multiple compatibility problems with ZFS,
|
|
especially with regards to newer ZFS features.
|
|
Workarounds have to be applied.
|
|
|
|
#. grub-probe fails to get canonical path
|
|
|
|
When persistent device names ``/dev/disk/by-id/*`` are used
|
|
with ZFS, GRUB will fail to resolve the path of the boot pool
|
|
device. Error::
|
|
|
|
# /usr/bin/grub-probe: error: failed to get canonical path of `/dev/virtio-pci-0000:06:00.0-part3'.
|
|
|
|
Solution::
|
|
|
|
echo 'export ZPOOL_VDEV_NAME_PATH=YES' >> /etc/profile.d/zpool_vdev_name_path.sh
|
|
source /etc/profile.d/zpool_vdev_name_path.sh
|
|
|
|
Note that ``sudo`` will not read ``/etc/profile`` and will
|
|
not pass variables in parent shell. Consider setting the following
|
|
in ``/etc/sudoers``::
|
|
|
|
pacman -S --noconfirm --needed sudo
|
|
echo 'Defaults env_keep += "ZPOOL_VDEV_NAME_PATH"' >> /etc/sudoers
|
|
|
|
#. Pool name missing
|
|
|
|
See `this bug report <https://savannah.gnu.org/bugs/?59614>`__.
|
|
Root pool name is missing from ``root=ZFS=rpool_$INST_UUID/ROOT/default``
|
|
kernel cmdline in generated ``grub.cfg`` file.
|
|
|
|
A workaround is to replace the pool name detection with ``zdb``
|
|
command::
|
|
|
|
sed -i "s|rpool=.*|rpool=\`zdb -l \${GRUB_DEVICE} \| grep -E '[[:blank:]]name' \| cut -d\\\' -f 2\`|" /etc/grub.d/10_linux
|
|
|
|
Install GRUB
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
#. Generate initrd::
|
|
|
|
rm -f /etc/zfs/zpool.cache
|
|
touch /etc/zfs/zpool.cache
|
|
chmod a-w /etc/zfs/zpool.cache
|
|
chattr +i /etc/zfs/zpool.cache
|
|
mkinitcpio -P
|
|
|
|
#. Create GRUB boot directory, in ESP and boot pool::
|
|
|
|
mkdir -p /boot/efi/EFI/arch
|
|
mkdir -p /boot/grub
|
|
|
|
Boot environment-specific configuration (kernel, etc)
|
|
is stored in ``/boot/grub/grub.cfg``, enabling rollback.
|
|
|
|
#. When in doubt, install both legacy boot
|
|
and EFI.
|
|
|
|
#. If using legacy booting, install GRUB to every disk::
|
|
|
|
for i in ${DISK}; do
|
|
grub-install --boot-directory /boot/efi/EFI/arch --target=i386-pc $i
|
|
done
|
|
|
|
#. If using EFI::
|
|
|
|
grub-install --boot-directory /boot/efi/EFI/arch --efi-directory /boot/efi/
|
|
grub-install --boot-directory /boot/efi/EFI/arch --efi-directory /boot/efi/ --removable
|
|
for i in ${DISK}; do
|
|
efibootmgr -cgp 1 -l "\EFI\arch\grubx64.efi" \
|
|
-L "arch-${i##*/}" -d ${i}
|
|
done
|
|
|
|
#. Generate GRUB Menu::
|
|
|
|
grub-mkconfig -o /boot/efi/EFI/arch/grub/grub.cfg
|
|
cp /boot/efi/EFI/arch/grub/grub.cfg /boot/grub/grub.cfg
|
|
|
|
#. For both legacy and EFI booting: mirror ESP content::
|
|
|
|
ESP_MIRROR=$(mktemp -d)
|
|
cp -r /boot/efi/EFI $ESP_MIRROR
|
|
for i in /boot/efis/*; do
|
|
cp -r $ESP_MIRROR/EFI $i
|
|
done
|
|
|
|
Enable Secure Boot
|
|
----------------------------
|
|
|
|
This is optional. `See Arch Wiki article <https://wiki.archlinux.org/title/Secure_Boot>`__.
|
|
|
|
Finish Installation
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
#. Exit chroot::
|
|
|
|
exit
|
|
|
|
#. Take a snapshot of the clean installation for future use::
|
|
|
|
zfs snapshot -r rpool_$INST_UUID/$INST_ID@install
|
|
zfs snapshot -r bpool_$INST_UUID/$INST_ID@install
|
|
|
|
#. Unmount EFI system partition::
|
|
|
|
umount /mnt/boot/efi
|
|
umount /mnt/boot/efis/*
|
|
|
|
#. Export pools::
|
|
|
|
zpool export bpool_$INST_UUID
|
|
zpool export rpool_$INST_UUID
|
|
|
|
#. Reboot::
|
|
|
|
reboot
|
|
|
|
Post installaion
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
#. If you have other data pools, generate list of datasets for `zfs-mount-generator
|
|
<https://manpages.ubuntu.com/manpages/focal/man8/zfs-mount-generator.8.html>`__ to mount them at boot::
|
|
|
|
DATA_POOL='tank0 tank1'
|
|
|
|
# tab-separated zfs properties
|
|
# see /etc/zfs/zed.d/history_event-zfs-list-cacher.sh
|
|
export \
|
|
PROPS="name,mountpoint,canmount,atime,relatime,devices,exec\
|
|
,readonly,setuid,nbmand,encroot,keylocation"
|
|
|
|
for i in $DATA_POOL; do
|
|
zfs list -H -t filesystem -o $PROPS -r $i > /etc/zfs/zfs-list.cache/$i
|
|
done
|
|
|
|
#. After reboot, consider adding a normal user::
|
|
|
|
myUser=UserName
|
|
zfs create $(df --output=source /home | tail -n +2)/${myUser}
|
|
useradd -MUd /home/${myUser} -c 'My Name' ${myUser}
|
|
zfs allow -u ${myUser} mount,snapshot,destroy $(df --output=source /home | tail -n +2)/${myUser}
|
|
chown -R ${myUser}:${myUser} /home/${myUser}
|
|
chmod 700 /home/${myUser}
|
|
passwd ${myUser}
|
|
|
|
Set up cron job to snapshot user home everyday::
|
|
|
|
pacman -S cronie
|
|
systemctl enable --now cronie
|
|
crontab -eu ${myUser}
|
|
#@daily zfs snap $(df --output=source /home/${myUser} | tail -n +2)@$(dd if=/dev/urandom of=/dev/stdout bs=1 count=100 2>/dev/null |tr -dc 'a-z0-9' | cut -c-6)
|
|
zfs list -t snapshot -S creation $(df --output=source /home/${myUser} | tail -n +2)
|
|
|
|
Install package groups::
|
|
|
|
pacman -Sg # query package groups
|
|
pacman -S 'gnome'
|
|
pacman -S 'plasma'
|
|
|