I wish to use sgdisk to delete all partition definitions and data from a storage device, then create a GPT and two partitions on it . The best solution I've found is to use the -Z
and the -o
options.
sgdisk -Zo \
-n 1::16M -t 1:EF00 -c 1:ZNX_BOOT \
-N 2 -t 2:8300 -c 2:ZNX_DATA /dev/[device]
This, however, fails if the drive was created with an MBR partition table or if a disk image was written to it. How can I get this command to wipe any disk regardless of the partition table style used on it?
Best Answer
I know this is changing the question but is it possible for you to use
wipefs
(which comes as part of theutil-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:WARNING: As the name suggests
wipefs
destroys data! Please be careful...