Skip to content

Commit 7bda340

Browse files
committed
Fix config drive writing script
When the deployment happens on a GPT disk with config drive, writing it to disk fails. Three reasons for that: * parted should be used instead of partprobe to determine the type of the disk; * gdisk -l sorts the partitions by their number, sort them by start sector instead; * after sgdisk completion, the configdrive device is not immediately visible in the /dev folder, udevadm settle needed here too. Closes-Bug: #1633063 Change-Id: Ifed89e343f9db4cf303baf7f8823342f6041f202
1 parent dca181a commit 7bda340

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ironic_python_agent/shell/copy_configdrive_to_disk.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ if [[ $? == 0 ]]; then
6262
else
6363

6464
# Check if it is GPT partition and needs to be re-sized
65-
partprobe $DEVICE print 2>&1 | grep "fix the GPT to use all of the space"
65+
parted $DEVICE print 2>&1 | grep "fix the GPT to use all of the space"
6666
if [[ $? == 0 ]]; then
6767
log "Fixing GPT to use all of the space on device $DEVICE"
6868
sgdisk -e $DEVICE || fail "move backup GPT data structures to the end of ${DEVICE}"
@@ -74,13 +74,14 @@ else
7474
EXISTING_PARTITION_LIST=$TEMP_DIR/existing_partitions
7575
UPDATED_PARTITION_LIST=$TEMP_DIR/updated_partitions
7676

77-
gdisk -l $DEVICE | grep -A$MAX_DISK_PARTITIONS "Number Start" | grep -v "Number Start" > $EXISTING_PARTITION_LIST
77+
# Sort partitions by second column, which is start sector
78+
gdisk -l $DEVICE | grep -A$MAX_DISK_PARTITIONS "Number Start" | grep -v "Number Start" | sort -k 2 > $EXISTING_PARTITION_LIST
7879

7980
# Create small partition at the end of the device
8081
log "Adding configdrive partition to $DEVICE"
8182
sgdisk -n 0:-64MB:0 $DEVICE || fail "creating configdrive on ${DEVICE}"
8283

83-
gdisk -l $DEVICE | grep -A$MAX_DISK_PARTITIONS "Number Start" | grep -v "Number Start" > $UPDATED_PARTITION_LIST
84+
gdisk -l $DEVICE | grep -A$MAX_DISK_PARTITIONS "Number Start" | grep -v "Number Start" | sort -k 2 > $UPDATED_PARTITION_LIST
8485

8586
CONFIG_PARTITION_ID=`diff $EXISTING_PARTITION_LIST $UPDATED_PARTITION_LIST | tail -n1 |awk '{print $2}'`
8687
ISO_PARTITION="${DEVICE}${CONFIG_PARTITION_ID}"
@@ -105,10 +106,9 @@ else
105106
# Find partition we just created
106107
# Dump all partitions, ignore empty ones, then get the last partition ID
107108
ISO_PARTITION=`sfdisk --dump $DEVICE | grep -v ' 0,' | tail -n1 | awk -F ':' '{print $1}' | sed -e 's/\s*$//'` || fail "finding ISO partition created on ${DEVICE}"
108-
109-
# Wait for udev to pick up the partition
110-
udevadm settle --exit-if-exists=$ISO_PARTITION
111109
fi
110+
# Wait for udev to pick up the partition
111+
udevadm settle --exit-if-exists=$ISO_PARTITION
112112
fi
113113

114114
# This writes the ISO image to the config drive.

0 commit comments

Comments
 (0)