From 5fcf3f066ccdbcc081ae35ab25f1c18737b94778 Mon Sep 17 00:00:00 2001 From: Olivier Bourdon Date: Thu, 17 May 2018 12:50:41 +0200 Subject: [PATCH] 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 --- ironic_python_agent/shell/write_image.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ironic_python_agent/shell/write_image.sh b/ironic_python_agent/shell/write_image.sh index c8cd38807..165d7176a 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"