arch installation mostly works with zfsbootmgr
This commit is contained in:
commit
1444f05d9c
19 changed files with 496 additions and 0 deletions
89
roles/base/templates/arch_chroot_install.sh
Normal file
89
roles/base/templates/arch_chroot_install.sh
Normal file
|
@ -0,0 +1,89 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
function add_admin_user {
|
||||
username="$1"
|
||||
id -u $username || useradd -m -G wheel $username
|
||||
id $username
|
||||
}
|
||||
|
||||
function install_paru_as {
|
||||
username="$1"
|
||||
if ! command -v paru 2>&1 >/dev/null; then
|
||||
sudo -u $username bash -c "cd ~; [ -d paru-bin ] || (git clone https://aur.archlinux.org/paru-bin.git && cd paru-bin && makepkg -si --noconfirm && paru -Sy)"
|
||||
sudo -u $username bash -c "rm -rf ~/paru-bin ~/.cache"
|
||||
fi
|
||||
}
|
||||
|
||||
function install_archzfs_pacman_repository {
|
||||
if grep -q "[archzfs]" /etc/pacman.conf; then
|
||||
echo "need to install archzfs pacman"
|
||||
fi
|
||||
}
|
||||
|
||||
function install_zfs_packages_as {
|
||||
username="$1"
|
||||
if ! pacman -Q zfs-dkms; then
|
||||
sudo -u $username -i bash -c "paru -Sy zfs-dkms --noconfirm"
|
||||
fi
|
||||
}
|
||||
|
||||
function configure_hostid {
|
||||
[ -f /etc/hostid ] || zgenhostid -f -o /etc/hostid
|
||||
hostid
|
||||
}
|
||||
|
||||
function install_zfsbootmenu {
|
||||
command -v wget || pacman -S --noconfirm wget
|
||||
if [ ! -f /boot/efi/EFI/zbm/zfsbootmenu.EFI ]; then
|
||||
mkdir -p /boot/efi/EFI/zbm/
|
||||
wget https://get.zfsbootmenu.org/latest.EFI -O /boot/efi/EFI/zbm/zfsbootmenu.EFI
|
||||
efibootmgr --disk {{ base_root_disks | first }} --part 1 --create \
|
||||
--label "ZFSBootMenu" \
|
||||
--loader '\EFI\zbm\zfsbootmenu.EFI' \
|
||||
--unicode "spl_hostid=$(hostid) zbm.timeout=3 zbm.prefer=zroot zbm.import_policy=hostid" \
|
||||
--verbose
|
||||
else
|
||||
echo "skipping zfsbootmenu installation"
|
||||
fi
|
||||
|
||||
zfs set org.zfsbootmenu:commandline="noresume init_on_alloc=0 rw spl.spl_hostid=$(hostid)" zroot/ROOT
|
||||
}
|
||||
|
||||
function configure_zfs_initrd {
|
||||
# Add 'zfs' to HOOKS=() before 'filesystem'
|
||||
sed -i '/^HOOKS=(/!b;/zfs/!s/filesystem/zfs filesystem/' /etc/mkinitcpio.conf
|
||||
# Add 'zfs' to MODULES=()
|
||||
sed -i '/^MODULES=/!b;/zfs/!s/)/zfs)/' /etc/mkinitcpio.conf
|
||||
initrd=/boot/initramfs-linux-lts.img
|
||||
[[ ! -e $initrd || $initrd -ot /etc/mkinitcpio.conf ]] || mkinitcpio -P
|
||||
# ^ only rebuild if initrd image is older than mkinitpio.conf
|
||||
}
|
||||
|
||||
function configure_dhcp_ethernet {
|
||||
cat <<- EOF > /etc/systemd/network/20-wired-dhcp.network
|
||||
[Match]
|
||||
Name=en*
|
||||
|
||||
[Link]
|
||||
RequiredForOnline=routable
|
||||
|
||||
[Network]
|
||||
DHCP=yes
|
||||
EOF
|
||||
systemctl enable systemd-networkd.service
|
||||
}
|
||||
|
||||
function enable_systemd_services {
|
||||
systemctl enable sshd.service
|
||||
}
|
||||
|
||||
# do the stuff
|
||||
add_admin_user mark
|
||||
install_paru_as mark
|
||||
install_zfs_packages_as mark
|
||||
configure_hostid
|
||||
install_zfsbootmenu
|
||||
configure_zfs_initrd
|
||||
configure_dhcp_ethernet
|
||||
enable_systemd_services
|
Loading…
Add table
Add a link
Reference in a new issue