From 3888a552fae8b94944c8951599b124b15977d911 Mon Sep 17 00:00:00 2001 From: Min Xu <24926999+min-xu-ai@users.noreply.github.com> Date: Wed, 5 Oct 2022 06:32:02 -0700 Subject: [PATCH] fix: Wait for device symlink after partitioning (#56) Co-authored-by: Min Xu --- scripts/functions.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/functions.sh b/scripts/functions.sh index 62921cb..12e18a7 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -239,6 +239,16 @@ function disk_create_partition() { sgdisk -n "0:0:$arg_size" -t "0:$type" -u "0:$partuuid" $extra_args "$device" >/dev/null \ || die "Could not create new gpt partition ($new_id) on '$device' ($id)" partprobe "$device" + + # On some system, we need to wait a bit for the $new_id symlink to show up. + local new_device + new_device="$(resolve_device_by_id "$new_id")" \ + || die "Could not resolve new device with id=$new_id" + for i in {1..10}; do + [[ -f "$new_device" ]] && break + echo "Waiting for partition $new_device to appear, $i second..." + sleep 1 + done } function disk_create_raid() {