summaryrefslogtreecommitdiff
path: root/ironic_python_agent/shell
diff options
context:
space:
mode:
authorOlivier Bourdon <obourdon@opennext.io>2018-05-17 12:50:41 +0200
committerOlivier Bourdon <obourdon@opennext.io>2018-05-17 12:51:55 +0200
commit5fcf3f066ccdbcc081ae35ab25f1c18737b94778 (patch)
treee975d2888f09405c820ba2458a871ac7525dcece /ironic_python_agent/shell
parent08890511599f97f71ec95149abcd1703ac060ed4 (diff)
downloadironic-python-agent-5fcf3f066ccdbcc081ae35ab25f1c18737b94778.tar.gz
Fix for fatal error when GPT was used and only MBR was cleaned
You can generate this error if after having provisioned a node using GPT partitioning, you clean its MBR using say dd if=/dev/zero bs=1024 count=1 of=/dev/sda and then cleanup all Ironic/Bifrost informations to get it reprovisioned. In this case sgdisk -Z returns an error and last_error field in Ironic contains: Error writing image to device: Writing image to device /dev/sda failed with exit code 2 Caution: invalid main GPT header, but valid backup; regenerating main header\nfrom backup!\n \nInvalid partition data!\ Change-Id: Ib617737fff5e40cb376edda0232e0726d9c71231
Diffstat (limited to 'ironic_python_agent/shell')
-rwxr-xr-xironic_python_agent/shell/write_image.sh2
1 files changed, 1 insertions, 1 deletions
diff --git a/ironic_python_agent/shell/write_image.sh b/ironic_python_agent/shell/write_image.sh
index c8cd3880..165d7176 100755
--- a/ironic_python_agent/shell/write_image.sh
+++ b/ironic_python_agent/shell/write_image.sh
@@ -36,7 +36,7 @@ DEVICE="$2"
# In production this will be replaced with secure erasing the drives
# For now we need to ensure there aren't any old (GPT) partitions on the drive
log "Erasing existing GPT and MBR data structures from ${DEVICE}"
-sgdisk -Z $DEVICE
+sgdisk -Z $DEVICE || sgdisk -o $DEVICE
log "Imaging $IMAGEFILE to $DEVICE"