How can I quickly clear GPT partition data from a disk?

Solution 1:

gdisk has an option for it. Open extended options, choose 'zap':

gdisk /dev/sda
> x
> z
> w (maybe?)

Solution 2:

This should do it pretty efficiently, based on the information about GPT on this site.

Clear the first block (two 512-byte sectors for MBR and header, and 16KiB for partition entries):

dd if=/dev/zero of=/dev/sdwhatever bs=512 count=34

The last part is trickier. I'm borrowing from this question to assist, although if you have ddrescue handy, it can go in reverse.

dd if=/dev/zero of=/dev/sdwhatever bs=512 count=34 seek=$((`blockdev --getsz /dev/sda` - 34))

Tags:

Linux

Gpt