How to remove GPT partition table in Linux


#1

I have an USB stick device which has an HFS volume with GPT partition table. I want to write an iso image to the stick with:

$ sudo dd if=debian-8.2.0-amd64-CD-1.iso of=/dev/sdb bs=8M

Command completed successfully but when I re-insert usb stick, it still tries to use information from GPT partition table.

So, I used gdisk utilitiy’s zap (destroy) GPT data structures option to remove GPT partition like below:

sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 0.8.10

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): x

Expert command (? for help): z
About to wipe out GPT on /dev/sdb. Proceed? (Y/N): Y
GPT data structures destroyed! You may now partition the disk using fdisk or
other utilities.
Blank out MBR? (Y/N): Y

After that I created a new DOS partition through fdisk and write iso image with dd. However, when I try to reinsert USB stick, it still identified with old information (as an hfsplus volume) in kernel:

GPT:Alternate GPT header not at the end of the disk.
GPT:1390003 != 15654847
GPT: Use GNU Parted to correct GPT errors.
sdb: sdb1 sdb2 sdb3
sd 13:0:0:0: [sdb] Attached SCSI removable disk
ISOFS: Unable to identify CD-ROM format.
hfsplus: invalid secondary volume header
hfsplus: unable to find HFS+ superblock

Restarting the Linux system doesn’t make sense too. So, how can I make a fresh MBR disk?


#2

I think you made everything in correct. So, probably your iso image contains a GPT partition which seen on after writing with dd.

You can check specific filesystem or partition table signatures in a device with wipefs command:

$ sudo wipefs /dev/sdb
offset               type
--------------------------------------------------
0x0                  mac   [partition table]
0x200                gpt   [partition table]
0x8001               iso9660   [filesystem]
                     LABEL: PVE
                     UUID:  2015-10-06-08-19-28-00

You can remove all of the signatures from the device (with the help of the -a parameter) before writing new iso image with dd. After iso image write process, you can check signatures again and compare with previous ones.

See also: man wipefs