Clear a Linux storage device with sgdisk

Solution 1:

I know this is changing the question but is it possible for you to use wipefs (which comes as part of the util-linux package)? wipefs understands how to clear all sorts of partition(ing) metadata and will correctly get rid of MBRs, GPTs (along with the backup GPT), filesystem signatures etc...

The examples from the EXAMPLES section at the bottom of the wipefs man page illustrate how you might do this:

wipefs /dev/sda*

Prints information about sda and all partitions on sda.

wipefs --all --backup /dev/sdb

Erases all signatures from the device /dev/sdb and creates a signature backup file ~/wipefs-sdb-<offset>.bak for each signature.

WARNING: As the name suggests wipefs destroys data! Please be careful...

Solution 2:

I reget I see no way to do that exclusively within sgdisk, but fortunately, the kind folks at Virtualhelp.me have suggested the use of dd first, i.e.,

dd if=/dev/zero of=/dev/sda bs=512 count=1

which is intended to overwrite that pesky MBR carrier partition which throws both sgdisk and gdisk for a loop.