summaryrefslogtreecommitdiff
path: root/ironic_python_agent/shell
diff options
context:
space:
mode:
Diffstat (limited to 'ironic_python_agent/shell')
-rwxr-xr-xironic_python_agent/shell/copy_configdrive_to_disk.sh24
1 files changed, 15 insertions, 9 deletions
diff --git a/ironic_python_agent/shell/copy_configdrive_to_disk.sh b/ironic_python_agent/shell/copy_configdrive_to_disk.sh
index 768a37da..da0b9097 100755
--- a/ironic_python_agent/shell/copy_configdrive_to_disk.sh
+++ b/ironic_python_agent/shell/copy_configdrive_to_disk.sh
@@ -34,15 +34,21 @@ DEVICE="$2"
[[ -f $CONFIGDRIVE ]] || usage "$CONFIGDRIVE (CONFIGDRIVE) is not a regular file"
[[ -b $DEVICE ]] || usage "$DEVICE (DEVICE) is not a block device"
-# Create small partition at the end of the device
-log "Adding configdrive partition to $DEVICE"
-parted -a optimal -s -- $DEVICE mkpart primary ext2 -64MiB -0
-
-# 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 '{print $1}'`
-
-# This generates the ISO image of the config drive.
+# Check for preexisting partition for configdrive
+EXISTING_PARTITION=`/sbin/blkid -l -o device $DEVICE -t LABEL=config-2`
+if [[ $? == 0 ]]; then
+ ISO_PARTITION=$EXISTING_PARTITION
+else
+ # Create small partition at the end of the device
+ log "Adding configdrive partition to $DEVICE"
+ parted -a optimal -s -- $DEVICE mkpart primary ext2 -64MiB -0
+
+ # 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 '{print $1}'`
+fi
+
+# This writes the ISO image to the config drive.
log "Writing Configdrive contents in $CONFIGDRIVE to $ISO_PARTITION"
dd if=$CONFIGDRIVE of=$ISO_PARTITION bs=64K oflag=direct