Relax partition refresh dependency
This commit is contained in:
parent
a6e5399572
commit
051485cede
@ -48,6 +48,20 @@ partition_path() {
|
||||
fi
|
||||
}
|
||||
|
||||
refresh_partition_table() {
|
||||
local disk="$1"
|
||||
|
||||
if command -v partprobe >/dev/null 2>&1; then
|
||||
partprobe "$disk"
|
||||
elif command -v partx >/dev/null 2>&1; then
|
||||
partx -u "$disk"
|
||||
elif command -v udevadm >/dev/null 2>&1; then
|
||||
udevadm settle
|
||||
else
|
||||
log_warn "No partition refresh tool available; proceeding without refresh."
|
||||
fi
|
||||
}
|
||||
|
||||
partition_disk() {
|
||||
: "${DISK:?Target disk is required}"
|
||||
: "${ESP_SIZE:?ESP size is required}"
|
||||
@ -65,7 +79,7 @@ partition_disk() {
|
||||
parted -s "$DISK" mkpart ESP fat32 1MiB "$ESP_SIZE"
|
||||
parted -s "$DISK" set 1 esp on
|
||||
parted -s "$DISK" mkpart ROOT "$ESP_SIZE" "$ROOT_END"
|
||||
partprobe "$DISK"
|
||||
refresh_partition_table "$DISK"
|
||||
|
||||
ESP_PART="$(partition_path "$DISK" 1)"
|
||||
ROOT_PART="$(partition_path "$DISK" 2)"
|
||||
|
||||
@ -41,6 +41,22 @@ require_command() {
|
||||
fi
|
||||
}
|
||||
|
||||
require_any_command() {
|
||||
local found=""
|
||||
local cmd
|
||||
|
||||
for cmd in "$@"; do
|
||||
if command -v "$cmd" >/dev/null 2>&1; then
|
||||
found="yes"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z "$found" ]]; then
|
||||
die "Missing required command: one of $*"
|
||||
fi
|
||||
}
|
||||
|
||||
sanity_check_base() {
|
||||
if [[ "$(id -u)" -ne 0 ]]; then
|
||||
die "Run this script as root."
|
||||
@ -57,7 +73,7 @@ sanity_check_base() {
|
||||
|
||||
sanity_check_commands() {
|
||||
require_command lsblk
|
||||
require_command partprobe
|
||||
require_any_command partprobe partx udevadm
|
||||
require_command parted
|
||||
require_command cryptsetup
|
||||
require_command mkfs.vfat
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user