Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for root device inside the initrd script for ISO images #4605

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 43 additions & 31 deletions pkg/mkimage-iso-efi/initrd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,52 @@ fi
echo "searching for root filesystem with value: $root_value"

rootdev=""
blkid=$(blkid)

# Determine if the root_value is a LABEL, UUID, or direct device path
while read -r line; do
case "$root_value" in
LABEL=*)
label=${root_value#LABEL=}
if echo "$line" | grep -q "LABEL=\"$label\""; then
rootdev=$(echo "$line" | cut -d: -f1)
break
fi
;;
UUID=*)
uuid=${root_value#UUID=}
if echo "$line" | grep -q "UUID=\"$uuid\""; then
rootdev=$(echo "$line" | cut -d: -f1)
break
fi
;;
PARTUUID=*)
partuuid=${root_value#PARTUUID=}
if echo "$line" | grep -q "PARTUUID=\"$partuuid\""; then
rootdev=$(echo "$line" | cut -d: -f1)
break
fi
;;
*)
rootdev="$root_value"
;;
esac
done <<EOF
$blkid
# Some emulated CD/DVD-ROM devices might take some time to appear in the
# system, set a maximum number of retries (one per second) until give up
cnt=10
while [ "$cnt" -gt 0 ]; do
# Determine if the root_value is a LABEL, UUID, or direct device path
while read -r line; do
case "$root_value" in
LABEL=*)
label=${root_value#LABEL=}
if echo "$line" | grep -q "LABEL=\"$label\""; then
rootdev=$(echo "$line" | cut -d: -f1)
break
fi
;;
UUID=*)
uuid=${root_value#UUID=}
if echo "$line" | grep -q "UUID=\"$uuid\""; then
rootdev=$(echo "$line" | cut -d: -f1)
break
fi
;;
PARTUUID=*)
partuuid=${root_value#PARTUUID=}
if echo "$line" | grep -q "PARTUUID=\"$partuuid\""; then
rootdev=$(echo "$line" | cut -d: -f1)
break
fi
;;
*)
rootdev="$root_value"
;;
esac
done <<EOF
$(blkid)
EOF

if [ -n "$rootdev" ]; then
break
else
echo "Waiting for root device... "
sleep 1
cnt=$((cnt - 1))
fi
done

# If root filesystem is found, mount it
if [ -n "$rootdev" ]; then
echo "found root filesystem: $rootdev, switching"
Expand Down
Loading