install.sh: fix four bugs found during live testing
Free-space start alignment
parted reports free space starting at 0,02 MiB (before the GPT
alignment boundary). The collect_free_space awk now rounds the start
up to the next whole MiB (ceiling) and enforces a minimum of 1 MiB,
then recomputes the usable size from the adjusted start. This prevents
parted from being asked to create a partition at 0 MiB, which it
cannot do.
Locale-independent partition creation
The previous `printf 'Yes\n' | parted mkpart` relied on parted
accepting an English answer to its alignment-confirmation prompt.
On a German-locale system parted asks "Ist dies noch akzeptabel?"
and ignores "Yes", causing mkpart to fail. Replaced with `parted -s`
(script/non-interactive mode), consistent with every other parted
call in the script.
Correct new-partition detection on disks with gaps
The old heuristic took the highest partition number after partprobe.
On a disk where existing partitions are numbered 2/3/4, a new
partition in the gap before them receives number 1 — making the
old heuristic point at partition 4 (the existing btrfs volume) and
subsequently run mkfs.btrfs on it. The new awk matches by start
position (OEMDRV_START ± 1 MiB) instead, which is unambiguous
regardless of how numbers are assigned.
Infinite loop on EOF stdin
When the selection while-loop's `read` hits EOF (e.g. stdin exhausted
after sudo consumed a piped password), it returns exit code 1 with an
empty INPUT, which falls through to "Invalid input." and spins
forever. Added `|| { echo; echo "Aborted."; exit 0; }` to all three
read calls in the loop.
install.md: drop stale install_from_repo.sh reference from title;
clarify that REPO_URL/REPO_BRANCH overrides are optional.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -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.
|
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
|
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
|
## After the script completes
|
||||||
|
|
||||||
|
|||||||
+13
-9
@@ -196,9 +196,12 @@ collect_free_space() {
|
|||||||
$1+0 > 0 {
|
$1+0 > 0 {
|
||||||
for (i = 1; i <= NF; i++) {
|
for (i = 1; i <= NF; i++) {
|
||||||
if ($i == "free") {
|
if ($i == "free") {
|
||||||
start=$2; end=$3; size=$4;
|
gsub(/MiB/,"",$2); gsub(/MiB/,"",$3);
|
||||||
gsub(/MiB/,"",start); gsub(/MiB/,"",end); gsub(/MiB/,"",size);
|
e=int($3+0);
|
||||||
s=int(start+0); e=int(end+0); sz=int(size+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;
|
if (sz >= min) print s " " e " " sz;
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -332,12 +335,12 @@ SEL=-1
|
|||||||
while true; do
|
while true; do
|
||||||
echo
|
echo
|
||||||
if [[ $FS_IDX -gt 0 && $shrink_count -gt 0 ]]; then
|
if [[ $FS_IDX -gt 0 && $shrink_count -gt 0 ]]; then
|
||||||
read -r -p "Enter f<n> to use free space, s<n> to shrink a partition, or q to quit: " INPUT
|
read -r -p "Enter f<n> to use free space, s<n> to shrink a partition, or q to quit: " INPUT || { echo; echo "Aborted."; exit 0; }
|
||||||
elif [[ $FS_IDX -gt 0 ]]; then
|
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}"
|
[[ "$INPUT" =~ ^[0-9]+$ ]] && INPUT="f${INPUT}"
|
||||||
else
|
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}"
|
[[ "$INPUT" =~ ^[0-9]+$ ]] && INPUT="s${INPUT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -458,15 +461,16 @@ fi
|
|||||||
# ── Create OEMDRV partition ───────────────────────────────────────────────────
|
# ── Create OEMDRV partition ───────────────────────────────────────────────────
|
||||||
|
|
||||||
info "Creating new OEMDRV partition (${OEMDRV_START}–${OEMDRV_END} MiB) on $WORK_DISK..."
|
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."
|
|| die "parted mkpart failed. Check that the target area is free space on $WORK_DISK."
|
||||||
|
|
||||||
partprobe "$WORK_DISK"
|
partprobe "$WORK_DISK"
|
||||||
sleep 1
|
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 \
|
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."
|
[[ -n "$NEW_PNUM" ]] || die "Could not determine new partition number on $WORK_DISK."
|
||||||
|
|
||||||
OEMDRV_DEV=$(new_part_device "$WORK_DISK" "$NEW_PNUM")
|
OEMDRV_DEV=$(new_part_device "$WORK_DISK" "$NEW_PNUM")
|
||||||
|
|||||||
Reference in New Issue
Block a user