0

I want to completely delete all GPT (meta)data off an USB drive, so I can create a fresh new GPT.
So I do:

sudo gpt destroy disk3

No errors, seems OK. However if I do:

sudo gpt -r show disk3

I get:

      start       size  index  contents
          0  245759967
  245759967         32         Sec GPT table
  245759999          1         Sec GPT header

So apparently there's still something left at the end of the drive. If I now do:

sudo gpt create disk3

I'm getting:

gpt create: disk3: error: device already contains a GPT

How do I completely get rid of all partitioning structures or GPT index or metadata backup headers or whatever is still there, and completely re-create a new, clean GPT from scratch?

  • 1
    Try it with the -r flag so it ensures that the table cannot be recovered. – Allan Mar 27 at 15:04
  • @Allan Tried that too, but made no difference. After destroy -r the Sec GPT table and header are still there. By the way I accidentally noticed that man gpt says "The -r option instructs gpt to destroy the table in a way that it can be recovered." I guess that's a typo and should be "can not". But either way, it didn't work with or without the -r. – RocketNuts Mar 27 at 15:53
  • Why not use diskutil partitionDisk function - that will most definitely destroy the GPT tables and write a new one with single command. – Allan Mar 27 at 15:57
  • It's not pure gpt, but how about dd-ing /dev/zero to the drive for a few seconds before you use gpt to rebuild?: sudo dd if=/dev/zero of=/dev/disk9 (change disk9 to your drive ID of choice. – Pete Cooper Mar 27 at 16:20
  • @Allen yes, thanks, that seems to do something, although that also automatically creates a 200MB EFI partition and in this particular case I want to avoid that. I want a completely empty GPT drive, and only create two partitions manually (and no implicit EFI partition). – RocketNuts Mar 27 at 22:17

You must log in to answer this question.

Browse other questions tagged .