fix: Wait for device symlink after partitioning (#56)

Co-authored-by: Min Xu <min.xu.public@gmail.com>
This commit is contained in:
Min Xu 2022-10-05 06:32:02 -07:00 committed by GitHub
parent d46010ba7b
commit 3888a552fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -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 \ 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)" || die "Could not create new gpt partition ($new_id) on '$device' ($id)"
partprobe "$device" 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() { function disk_create_raid() {