Compare commits

...

11 Commits

Author SHA1 Message Date
77b736fb8c refactor(script): Update archlinux-keyring before pacstrap 2026-01-18 22:02:26 +01:00
363d547e75 refactor(script): paru-git instead of paru-bin 2026-01-18 22:00:24 +01:00
2e76f90f81 Merge pull request 'fix/28-detect-efi-on-nvme' (#29) from fix/28-detect-efi-on-nvme into main
Reviewed-on: #29
2025-12-13 17:05:42 +00:00
15d18f930e fix(base): Load udev initramfs hook (#28)
This replaces the modern Arch Linux default hook of 'systemd' with
'udev' which allows a clean boot of a boot environment via ZFSBootMenu.
2025-12-13 16:57:59 +01:00
bf46d15783 fix(base): Detect EFI partition on NVMe (#28)
This detects an EFI partition on '/dev/sda1' (same as before) as well
as on '/dev/nvme0n1p1' (new) where there are not just letters in
front of partition number '1'.
2025-12-13 00:04:30 +01:00
15d67f2e3f Merge pull request '26-install-zfs-only-when-needed' (#27) from 26-install-zfs-only-when-needed into main
Reviewed-on: #27
2025-01-17 20:11:11 +00:00
6fb13a097c Merge remote-tracking branch 'origin/26-install-zfs-only-when-needed' into 26-install-zfs-only-when-needed 2025-01-17 21:09:40 +01:00
64c66cbd0f fix(zfs): Install ZFS only when needed (#26)
In situations where this script runs on alternative Arch Linux live
CD ISOs such as github.com/stevleibelt/arch-linux-live-cd-iso-with
-zfs we may not have to insall ZFS kernel modules. Test if the 'zfs'
module is loaded and skip installation if yes.
2025-01-17 21:09:19 +01:00
1036ce9c5b fix(zfs): Install ZFS only when needed (#26)
In situations where this script runs on alternative Arch Linux live
CD ISOs such as github.com/stevleibelt/arch-linux-live-cd-iso-with
-zfs we may not have to insall ZFS kernel modules. Test if the 'zfs'
module is loaded and skip installation if yes.
2025-01-17 21:08:44 +01:00
3ae8b53616 build(meta): Don't commit .idea JetBrains dir (#26) 2025-01-17 21:05:53 +01:00
2adac7b94b Add a 2G loop device for emergency swap 2025-01-02 01:00:06 +01:00
2 changed files with 66 additions and 10 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
archzbm_settings.env
.idea

View File

@@ -451,7 +451,12 @@ function install_pkgs () {
function install_zfs () {
#1.6
declare reset_colors='\033[0m'
curl -s 'https://raw.githubusercontent.com/eoli3n/archiso-zfs/master/init' | bash
if modinfo 'zfs' &>/dev/null; then
>&3 printf -- '%s\n' \
'ZFS kernel module is loaded, no need to install ...'
else
curl -s 'https://raw.githubusercontent.com/eoli3n/archiso-zfs/master/init' | bash
fi
printf -- "${reset_colors}"
}
@@ -773,6 +778,7 @@ function install_archlinux () {
#1.12
pacman_dl_parallel
pacman_dont_check_space
pacman --noconfirm -S archlinux-keyring
while ! pacstrap /mnt \
base \
base-devel \
@@ -931,8 +937,49 @@ function add_zfs_hook_to_initramfs () {
'/mnt/etc/mkinitcpio.conf'
}
function set_initramfs_build_list () {
function replace_systemd_initramfs_with_udev () {
#1.17
# Replace systemd-boot hooks with udev hooks in initramfs. For some odd
# reason we have not yet understood the modern default on a fresh Arch
# Linux installation ('systemd' and 'sd-vconsole' hooks) doesn't cleanly
# boot into a boot environment via ZFSBootMenu.
#
# 1. If we left both hooks in place we'd see an error related
# to '/dev/gpt-auto-root'; that can be worked around by loading the 'vfat'
# module via the 'MODULES=(...)' array in '/etc/mkinitcpio.conf'.
#
# 2. On next try we see the system failing into an emergency shell at a
# later point in initramfs execution due to a failure with
# 'initrd-switch-root.service'. Since the 'systemd' hook disables the
# 'root' account we enter a non-functional emergency shell. See
# https://wiki.archlinux.org/title/Mkinitcpio section 6.7 "Cannot open
# access to console, the root account is locked" where we learn that we can
# install AUR package initcpio-hook-shadowcopy and load the 'shadowcopy'
# hook right after the 'systemd' hook in order to get a fully functional
# emergency shell.
#
# 3. On next try 'initrd-switch-root.service' fails into a functional
# emergency shell which allows us to check systemd status of
# 'initrd-switch-root.service'. This seems to tell us that '/sysroot' is
# wanted but missing which appears to be true.
#
# At this point in December 2025 we stopped investigating how to properly
# pair 'systemd' and 'sd-vconsole' hooks with ZFSBootMenu. We're instead
# replacing both as follows:
#
# systemd <--> udev
# sd-vconsole <--> consolefont
#
# This cleanly boots a boot environment. Further investigation may be
# warranted at a later date. For now this workaround is good enough.
in_file_in_array_insert_n_before_m '/mnt/etc/mkinitcpio.conf' 'HOOKS' 'udev' 'systemd'
in_file_in_array_remove_n '/mnt/etc/mkinitcpio.conf' 'HOOKS' 'systemd'
in_file_in_array_insert_n_before_m '/mnt/etc/mkinitcpio.conf' 'HOOKS' 'consolefont' 'sd-vconsole'
in_file_in_array_remove_n '/mnt/etc/mkinitcpio.conf' 'HOOKS' 'sd-vconsole'
}
function set_initramfs_build_list () {
#1.18
# No need to build fallback initramfs, our new fallback is ZFS snapshots
sed -ri \
-e '/^#/d' \
@@ -946,7 +993,7 @@ function set_initramfs_build_list () {
}
function add_zfs_files_to_new_os () {
#1.18
#1.19
for zfs_file in '/etc/hostid' '/etc/zfs/zpool.cache' $([[ ! "${ARCHZBM_ZFSPROPS_NO_ENCRYPTION}" ]] && printf -- '%s' '/etc/zfs/'"${zpool_name}"'.key'); do
rsync -av --itemize-changes {'','/mnt'}"${zfs_file}"
done
@@ -1046,12 +1093,12 @@ function get_aur_helper () {
usermod --append --groups 'wheel' 'build'
printf -- '%s\n' '%wheel ALL=(ALL:ALL) NOPASSWD: ALL' > '/etc/sudoers.d/10-wheel-group-no-passwd-prompt'
pushd /tmp
git clone https://aur.archlinux.org/paru-bin.git
chown -R 'build:' 'paru-bin'
pushd 'paru-bin'
git clone https://aur.archlinux.org/paru-git.git
chown -R 'build:' 'paru-git'
pushd 'paru-git'
sudo --user 'build' makepkg -si --noconfirm
popd
rm -rf 'paru-bin'
rm -rf 'paru-git'
popd
}
@@ -1290,7 +1337,7 @@ function get_disks_with_one_efipart () {
# Find disks that have exactly one EFI partition and where that EFI
# partition is partition number 1. We expect exactly one disk to meet
# these criteria. Anything else and we bail.
disks_with_one_efipart="$(lsblk --output PATH,PARTTYPE --json --tree | jq --raw-output '.[][] | select(.children | length > 0) | select( any (.children[]; (.path | test("^[^[:digit:]]+1")) and (.parttype=="'"${partition_types[gpt_efi]}"'")) and ([select(.children[].parttype=="'"${partition_types[gpt_efi]}"'")] | length == 1) ) | .path')"
disks_with_one_efipart="$(lsblk --output PATH,PARTTYPE --json --tree | jq --raw-output '.[][] | select(.children | length > 0) | select( any (.children[]; (.path | test("^[^[:digit:]]+(.*?[[:digit:]]+p)?1")) and (.parttype=="'"${partition_types[gpt_efi]}"'")) and ([select(.children[].parttype=="'"${partition_types[gpt_efi]}"'")] | length == 1) ) | .path')"
if [[ "$(wc -l <<<"${disks_with_one_efipart}")" -eq '1' ]] && [[ "$(wc -c <<<"${disks_with_one_efipart}")" -gt '1' ]]; then
printf -- '%s' "${disks_with_one_efipart}"
return 0
@@ -1300,6 +1347,10 @@ function get_disks_with_one_efipart () {
function install_os_in_chroot () {
#2.2
dd if='/dev/zero' of='/swapfile' bs='1M' count='2048'
losetup '/dev/loop9' '/swapfile'
mkswap '/dev/loop9'
swapon '/dev/loop9'
### Reinit keyring
# As keyring is initialized at boot, and copied to the install dir with pacstrap, and ntp is running
# Time changed after keyring initialization, it leads to malfunction
@@ -1346,6 +1397,9 @@ function install_os_in_chroot () {
add_syslinux_pacman_hook
fi
add_zbm_pacman_hook
swapoff '/dev/loop9'
losetup -d '/dev/loop9'
rm '/swapfile'
}
function set_root_pw () {
@@ -1567,8 +1621,9 @@ function main () {
set_hostname #1.14
set_locale #1.15
add_zfs_hook_to_initramfs #1.16
set_initramfs_build_list #1.17
add_zfs_files_to_new_os #1.18
replace_systemd_initramfs_with_udev #1.17
set_initramfs_build_list #1.18
add_zfs_files_to_new_os #1.19
enter_chroot #2.1
# We're done in chroot
finalize_os_setup #3.1