From 7406a55fa0e384a9419ceb026e99761a731b3c39 Mon Sep 17 00:00:00 2001 From: Min Xu Date: Mon, 3 Oct 2022 22:05:39 -0700 Subject: [PATCH] wait for device symlink --- scripts/functions.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/functions.sh b/scripts/functions.sh index 62921cb..599ed13 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -239,6 +239,17 @@ 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 `seq 10`; do + if [ -f "$new_device" ]; then + break + fi + sleep 1 + done } function disk_create_raid() {