diff --git a/install.md b/install.md index d9c91ed..6a9a284 100644 --- a/install.md +++ b/install.md @@ -1,4 +1,4 @@ -# OEMDRV Bootstrap — install.sh + install_from_repo.sh +# OEMDRV Bootstrap — install.sh the script `./system_setup/install.sh` prepares a target machine for automated Fedora deployment. It shrinks an existing partition to carve out a dedicated **OEMDRV** partition, which Anaconda/Kickstart will detect automatically during installation. @@ -37,7 +37,7 @@ curl -fsSL ${REPO_URL%.git}/raw/branch/${REPO_BRANCH:-main}/system_setup/install sudo -E bash /tmp/install.sh ``` -That way, install.sh should know what to pull. +Both are optional. That way, install.sh should know what to pull. ## After the script completes diff --git a/system_setup/install.sh b/system_setup/install.sh index 5191cac..ee7293e 100755 --- a/system_setup/install.sh +++ b/system_setup/install.sh @@ -196,9 +196,12 @@ collect_free_space() { $1+0 > 0 { for (i = 1; i <= NF; i++) { if ($i == "free") { - start=$2; end=$3; size=$4; - gsub(/MiB/,"",start); gsub(/MiB/,"",end); gsub(/MiB/,"",size); - s=int(start+0); e=int(end+0); sz=int(size+0); + gsub(/MiB/,"",$2); gsub(/MiB/,"",$3); + e=int($3+0); + raw_s=$2+0; + s=int(raw_s)+(raw_s>int(raw_s)?1:0); + if (s < 1) s = 1; + sz=e-s; if (sz >= min) print s " " e " " sz; break } @@ -332,12 +335,12 @@ SEL=-1 while true; do echo if [[ $FS_IDX -gt 0 && $shrink_count -gt 0 ]]; then - read -r -p "Enter f to use free space, s to shrink a partition, or q to quit: " INPUT + read -r -p "Enter f to use free space, s to shrink a partition, or q to quit: " INPUT || { echo; echo "Aborted."; exit 0; } elif [[ $FS_IDX -gt 0 ]]; then - read -r -p "Enter number of free space region to use, or q to quit: " INPUT + read -r -p "Enter number of free space region to use, or q to quit: " INPUT || { echo; echo "Aborted."; exit 0; } [[ "$INPUT" =~ ^[0-9]+$ ]] && INPUT="f${INPUT}" else - read -r -p "Enter number of partition to shrink, or q to quit: " INPUT + read -r -p "Enter number of partition to shrink, or q to quit: " INPUT || { echo; echo "Aborted."; exit 0; } [[ "$INPUT" =~ ^[0-9]+$ ]] && INPUT="s${INPUT}" fi @@ -458,15 +461,16 @@ fi # ── Create OEMDRV partition ─────────────────────────────────────────────────── info "Creating new OEMDRV partition (${OEMDRV_START}–${OEMDRV_END} MiB) on $WORK_DISK..." -printf 'Yes\n' | parted "$WORK_DISK" mkpart anacondainstall btrfs "${OEMDRV_START}MiB" "${OEMDRV_END}MiB" \ +parted -s "$WORK_DISK" mkpart anacondainstall btrfs "${OEMDRV_START}MiB" "${OEMDRV_END}MiB" \ || die "parted mkpart failed. Check that the target area is free space on $WORK_DISK." partprobe "$WORK_DISK" sleep 1 -# Determine new partition number (highest on the disk after partprobe) +# Find the partition whose start matches OEMDRV_START (±1 MiB for alignment) NEW_PNUM=$(parted -s "$WORK_DISK" -m unit MiB print 2>/dev/null \ - | awk -F: '/^[0-9]/{n=$1} END{print n}') + | awk -F: -v s="$OEMDRV_START" ' + /^[0-9]/ { gsub(/MiB/,"",$2); if (int($2+0) >= s-1 && int($2+0) <= s+1) { print $1; exit } }') [[ -n "$NEW_PNUM" ]] || die "Could not determine new partition number on $WORK_DISK." OEMDRV_DEV=$(new_part_device "$WORK_DISK" "$NEW_PNUM")