This is not a bug in sgdisk; it's either a bug in the charm or an
incorrect use of same. Specifically, the sgdisk command shown is:

sgdisk --zap-all --clear --mbrtogpt /dev/vdb

This command does four things, in sequence:

- It zaps all GPT and MBR data structures (--zap-all).
- It creates an empty GPT data structure (--clear).
- It OKs the conversion of any MBR data structure to GPT form (--mbrtogpt).
- It writes the resulting changes to disk. (This is implicit in most uses of 
sgdisk.)

The first and second of those options are both used to wipe data, but in
different ways -- --zap-all zeroes out all the sectors of the disk used
by the GPT data structures, whereas --clear erases the partitions but
leaves the data structures intact. Using --clear after --zap-all should
therefore have the same effect as using --clear alone. (There may be
cases where --zap-all would be necessary if you're dealing with a
damaged disk, but I'd need to study this some more to be sure.) In any
event, the end result of those two commands is a GPT disk with no
partitions defined, not a disk without a partition table.

The --mbrtogpt option is useless in this context. It should be used when
you want to convert an MBR disk to GPT form, but as the preceding
options set the disk up as GPT, --mbrtogpt does nothing.

If the goal is to completely erase all partition data, including the
partition table itself, the following command should be used:

sgdisk --zap-all /dev/vdb

Adding --clear and --mbrtogpt will be useless at best, and as you've
discovered, --clear adds an (empty) partition table back. Note also that
parted does *NOT* show that the disk is "all clear," as described in the
bug report:

# parted shows that it's call clear
% parted /dev/vdb print

Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags

Note the line that reads "Partition Table: gpt," which indicates that a
valid GPT is present on the disk. No partitions are listed because that
was the effect of the --clear option to sgdisk. Naturally, fdisk also
notes the GPT data structures in the protective MBR.

-- 
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/1303903

Title:
  sgdisk zap/clear doesn't wipe all GPT tables

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gdisk/+bug/1303903/+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

Reply via email to