I'm the upstream author of GPT fdisk. The intent of the "3" return code is to signal when sgdisk failed to operate because the disk was a non-GPT disk -- for instance, a "-d" operation to delete a partition, which sgdisk will refuse to do on an MBR disk unless "-g" is also included, to make it clear that the user (or script) intends to convert from MBR to GPT.
The "-b" option will complete successfully on an MBR disk, although the backup data won't reflect the MBR data as it was, since it will be a GPT-converted version of the MBR data. This makes this particular case a bit ambiguous: sgdisk CAN do as it was asked, but the resulting data might not be useful. IMO, it's better to know the partition table type BEFORE using sgdisk than to rely on sgdisk to return an error code if you use it inappropriately. You can learn the partition table type with "gdisk -l /dev/sdx" or "parted /dev/sdx print" and grepping on appropriate output lines. Another consideration is that there may be existing scripts that rely on sgdisk creating a "backup" GPT data file even of MBR disks. This would be a little weird, but I can't rule out the possibility that somebody would want to do this, and I'm reluctant to introduce a change to sgdisk that would break somebody's scripts. For these reasons, I've introduced changes upstream to the man page to more clearly describe the fact that the "3" return value occurs only when sgdisk doesn't do what it's asked to do because of the fact that it was launched on a non-GPT disk, not whenever it was launched on a non- GPT disk even if it could do what it was asked to do. -- You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to gdisk in Ubuntu. https://bugs.launchpad.net/bugs/1445456 Title: sgdisk return 0 if nonGPT partition style (must return 3) To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/gdisk/+bug/1445456/+subscriptions -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs