diff options
author | Vladyslav Drok <vdrok@mirantis.com> | 2016-10-13 15:28:04 +0300 |
---|---|---|
committer | Dmitry Tantsur <divius.inside@gmail.com> | 2016-11-02 11:16:17 +0000 |
commit | f52e88301068ade6add74906843e2063ef87826a (patch) | |
tree | 1ba026c26413370f0942fd4a49db0f7e286598e7 | |
parent | c4697899d4fbc73479bc7de4fbdd094958a6b248 (diff) | |
download | ironic-python-agent-f52e88301068ade6add74906843e2063ef87826a.tar.gz |
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
(cherry picked from commit 7bda3408f5bef4349c4e3537f3c8c0826a5dead8)
-rwxr-xr-x | ironic_python_agent/shell/copy_configdrive_to_disk.sh | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ironic_python_agent/shell/copy_configdrive_to_disk.sh b/ironic_python_agent/shell/copy_configdrive_to_disk.sh index 711fb63f..b62ba6b9 100755 --- a/ironic_python_agent/shell/copy_configdrive_to_disk.sh +++ b/ironic_python_agent/shell/copy_configdrive_to_disk.sh @@ -62,7 +62,7 @@ if [[ $? == 0 ]]; then else # Check if it is GPT partition and needs to be re-sized - partprobe $DEVICE print 2>&1 | grep "fix the GPT to use all of the space" + parted $DEVICE print 2>&1 | grep "fix the GPT to use all of the space" if [[ $? == 0 ]]; then log "Fixing GPT to use all of the space on device $DEVICE" sgdisk -e $DEVICE || fail "move backup GPT data structures to the end of ${DEVICE}" @@ -74,13 +74,14 @@ else EXISTING_PARTITION_LIST=$TEMP_DIR/existing_partitions UPDATED_PARTITION_LIST=$TEMP_DIR/updated_partitions - gdisk -l $DEVICE | grep -A$MAX_DISK_PARTITIONS "Number Start" | grep -v "Number Start" > $EXISTING_PARTITION_LIST + # Sort partitions by second column, which is start sector + gdisk -l $DEVICE | grep -A$MAX_DISK_PARTITIONS "Number Start" | grep -v "Number Start" | sort -k 2 > $EXISTING_PARTITION_LIST # Create small partition at the end of the device log "Adding configdrive partition to $DEVICE" sgdisk -n 0:-64MB:0 $DEVICE || fail "creating configdrive on ${DEVICE}" - gdisk -l $DEVICE | grep -A$MAX_DISK_PARTITIONS "Number Start" | grep -v "Number Start" > $UPDATED_PARTITION_LIST + gdisk -l $DEVICE | grep -A$MAX_DISK_PARTITIONS "Number Start" | grep -v "Number Start" | sort -k 2 > $UPDATED_PARTITION_LIST CONFIG_PARTITION_ID=`diff $EXISTING_PARTITION_LIST $UPDATED_PARTITION_LIST | tail -n1 |awk '{print $2}'` ISO_PARTITION="${DEVICE}${CONFIG_PARTITION_ID}" @@ -105,10 +106,9 @@ else # Find partition we just created # Dump all partitions, ignore empty ones, then get the last partition ID 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}" - - # Wait for udev to pick up the partition - udevadm settle --exit-if-exists=$ISO_PARTITION fi + # Wait for udev to pick up the partition + udevadm settle --exit-if-exists=$ISO_PARTITION fi # This writes the ISO image to the config drive. |