Skip to content

Commit

Permalink
#13 more reliable udev disk identify & ensure packages present
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsimpson committed Nov 23, 2024
1 parent 157eff4 commit 7e9f2f3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
set -x
set -eux -o pipefail

# The two smallest disks are always used as the boot and root pool
# as a ZFS mirror.
Expand All @@ -9,6 +9,9 @@ set -x
# - Based on manual steps in OpenZFS docs:
# https://openzfs.github.io/openzfs-docs/Getting%20Started/Fedora/Root%20on%20ZFS.html#:~:text=page%20for%20examples.-,Declare%20disk%20array,-DISK%3D%27/dev

install_required_packages() {
apk add lsblk eudev jq curl arch-install-scripts eudev sgdisk wipefs parted findmnt
}

declare_disk_array() {
# For each disk found, get it's /dev/disk/by-id address by querying udevadm
Expand All @@ -19,7 +22,7 @@ declare_disk_array() {

for DISK_ADDRESS in $DISK_ADDRESSES
do
DISK_UDEV_PATH=/dev/$(udevadm info --query=symlink --name=/dev/"$DISK_ADDRESS"| cut -d ' ' -f 1)
DISK_UDEV_PATH=/dev/$(udevadm info --query=symlink --name=/dev/"$DISK_ADDRESS"| awk '{for(i=1; i<=NF; i++) if($i ~ /^disk\/by-id\//) {print $i; exit}}')
# Append disk to $DISK list
DISK="$DISK $DISK_UDEV_PATH"
done
Expand Down Expand Up @@ -165,7 +168,6 @@ format_and_mount_ESP(){
}

download_extract_minimal_Fedora_root_filesystem(){
apk add curl
curl --fail-early --fail -L \
https://dl.fedoraproject.org/pub/fedora/linux/releases/38/Container/x86_64/images/Fedora-Container-Base-38-1.6.x86_64.tar.xz \
-o rootfs.tar.gz
Expand Down Expand Up @@ -200,7 +202,6 @@ enable_community_repo(){


generate_fstab(){
apk add arch-install-scripts
genfstab -t PARTUUID "${MNT}" \
| grep -v swap \
| sed "s|vfat.*rw|vfat rw,x-systemd.idle-timeout=1min,x-systemd.automount,noauto,nofail|" \
Expand Down Expand Up @@ -417,6 +418,7 @@ ZFS_export_all_pools(){
zpool export -a
}

install_required_packages
declare_disk_array
set_mount_point
set_swap_size
Expand Down
4 changes: 4 additions & 0 deletions src/playbooks/templates/interfaces.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
iface {{ server_active_gateway_interface.stdout }} inet static
address {{ server_public_ip.stdout }}
netmask {{ server_ip_netmask.stdout }}
gateway {{ server_gateway_ip.stdout }}

0 comments on commit 7e9f2f3

Please sign in to comment.