ironic runs the command below but encounters the following:
[root@overcloud-compute-0 ~]# sgdisk -Z /dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:5:0
Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!
Warning! One or more CRCs don't match. You should repair the disk!
Invalid partition data!
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
[root@overcloud-compute-0 ~]#
Because the return code is non-zero its registered as an error and disk cleaning fails.
One workaround I found was to use gdisk create a blank GPT:
[root@overcloud-compute-0 ~]# gdisk /dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:5:0
GPT fdisk (gdisk) version 0.8.6
Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!
Warning! One or more CRCs don't match. You should repair the disk!
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: damaged
Found invalid MBR and corrupt GPT. What do you want to do? (Using the
GPT MAY permit recovery of GPT data.)
1 - Use current GPT
2 - Create blank GPT
Your answer: 2
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:5:0.
The operation has completed successfully.
[root@overcloud-compute-0 ~]#
after the above I can run the same command and not get a non-zero return code.
[root@overcloud-compute-0 ~]# sgdisk -Z /dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:5:0
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
[root@overcloud-compute-0 ~]# echo $?
0
[root@overcloud-compute-0 ~]#
[root@overcloud-compute-0 ~]# sgdisk --version
GPT fdisk (sgdisk) version 0.8.6
"GPT adds CRC32 checksums to its data structures and stores those structures twice on the disk—once at the start of the disk and again at the end. These measures help protect the system against accidental damage caused by carelessness or disk errors."
It almost seems like an sgdisk bug that it should care about its own CRC check if we've asked it to delete its CRC structure anyway with -Z, which by definition, destroys GPT and MBR data structures.
Here's what I think is happening:
ironic runs the command below but encounters the following:
[root@overcloud -compute- 0 ~]# sgdisk -Z /dev/disk/ by-path/ pci-0000: 03:00.0- scsi-0: 2:5:0
Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!
Warning! One or more CRCs don't match. You should repair the disk!
Invalid partition data! -compute- 0 ~]#
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
[root@overcloud
[root@overcloud -compute- 0 ~]# echo $? -compute- 0 ~]#
2
[root@overcloud
Because the return code is non-zero its registered as an error and disk cleaning fails.
One workaround I found was to use gdisk create a blank GPT:
[root@overcloud -compute- 0 ~]# gdisk /dev/disk/ by-path/ pci-0000: 03:00.0- scsi-0: 2:5:0
GPT fdisk (gdisk) version 0.8.6
Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!
Warning! One or more CRCs don't match. You should repair the disk!
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: damaged
Found invalid MBR and corrupt GPT. What do you want to do? (Using the
GPT MAY permit recovery of GPT data.)
1 - Use current GPT
2 - Create blank GPT
Your answer: 2
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y by-path/ pci-0000: 03:00.0- scsi-0: 2:5:0. -compute- 0 ~]#
OK; writing new GUID partition table (GPT) to /dev/disk/
The operation has completed successfully.
[root@overcloud
after the above I can run the same command and not get a non-zero return code.
[root@overcloud -compute- 0 ~]# sgdisk -Z /dev/disk/ by-path/ pci-0000: 03:00.0- scsi-0: 2:5:0 -compute- 0 ~]# echo $? -compute- 0 ~]#
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
[root@overcloud
0
[root@overcloud
[root@overcloud -compute- 0 ~]# sgdisk --version
GPT fdisk (sgdisk) version 0.8.6
[root@overcloud -compute- 0 ~]#
As per https:/ /www.rodsbooks. com/gdisk/ whatsgpt. html:
"GPT adds CRC32 checksums to its data structures and stores those structures twice on the disk—once at the start of the disk and again at the end. These measures help protect the system against accidental damage caused by carelessness or disk errors."
It almost seems like an sgdisk bug that it should care about its own CRC check if we've asked it to delete its CRC structure anyway with -Z, which by definition, destroys GPT and MBR data structures.