1

In the fdisk area, cleaning out the MBR would require writing 446 bytes, and to include cleaning of the partition information, zero-ing the first 512 bytes was enough:

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

Is cleaning out 512 bytes enough for parted to no longer recognise some old partition table information?

1

Writing 512 bytes is not enough, you need to clean out at least two 512 byte blocks.
If you start with a pristine disc:

# dd if=/dev/sdb bs=512 count=80000 | od -c
0000000  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
234200000
80000+0 records in
80000+0 records out
40960000 bytes (41 MB) copied, 0.99129 s, 41.3 MB/s

Then start parted and create a partition:

# parted
(parted) unit GB
(parted) mklabel gpt                                                      
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 2.15GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End  Size  File system  Name  Flags

(parted) mkpart primary 0 2
(parted) print                                                            
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 2.15GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      0.00GB  2.15GB  2.15GB               primary

(parted) quit                                                             
Information: You may need to update /etc/fstab.

And look at the disk once more, you can see there is more than 512 bytes of data written:

# dd if=/dev/sdb bs=512 count=80000 | od -c
0000000  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
0000700 001  \0 356 376 377 377 001  \0  \0  \0 037   -   @  \0  \0  \0
0000720  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
0000760  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0   U 252
0001000   E   F   I       P   A   R   T  \0  \0 001  \0   \  \0  \0  \0
0001020 351 356   t 217  \0  \0  \0  \0 001  \0  \0  \0  \0  \0  \0  \0
0001040 037   -   @  \0  \0  \0  \0  \0   "  \0  \0  \0  \0  \0  \0  \0
0001060 376   ,   @  \0  \0  \0  \0  \0   n   T   l 342 306 351   ^   E
0001100 237   ~   i 270   t 034 227 004 002  \0  \0  \0  \0  \0  \0  \0
0001120 200  \0  \0  \0 200  \0  \0  \0   /  \n   Z 202  \0  \0  \0  \0
0001140  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
0002000 257   = 306 017 203 204   r   G 216   y   =   i 330   G   } 344
0002020   _   _ 344   4 257   / 276   G 226 375   n 244 332   P 230 224
0002040  \0  \b  \0  \0  \0  \0  \0  \0 377   '   @  \0  \0  \0  \0  \0
0002060  \0  \0  \0  \0  \0  \0  \0  \0   p  \0   r  \0   i  \0   m  \0
0002100   a  \0   r  \0   y  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
0002120  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0  \0
*
234200000
80000+0 records in
80000+0 records out
40960000 bytes (41 MB) copied, 0.988582 s, 41.4 MB/s

Then, if you only clean out the first 512 bytes, parted finds some information :

# dd if=/dev/zero of=/dev/sdb bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.0030505 s, 168 kB/s
lm17base avanderneut # parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Warning: /dev/sdb contains GPT signatures, indicating that it has a GPT table.
However, it does not have a valid fake msdos partition table, as it should.
Perhaps it was corrupted -- possibly by a program that doesn't understand GPT
partition tables.  Or perhaps you deleted the GPT table, and are now using an
msdos partition table.  Is this a GPT partition table?
Yes/No? No                                                                
(parted) quit 

You need to clean out two blocks to get rid of this message:

# dd if=/dev/zero of=/dev/sdb bs=512 count=2
2+0 records in
2+0 records out
1024 bytes (1.0 kB) copied, 0.00469557 s, 218 kB/s
# parted /dev/sdb
GNU Parted 2.3
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Error: /dev/sdb: unrecognised disk label                                  
(parted) quit  

Cleaning all the information written at the beginning of the disc requires zero-ing at least three (1 partition) 512 bytes blocks. For 10 partitions this increases to five blocks.


A copy of the partition table is written at the end of the disc. If you use sgdisk to make a backup of the partition table, then write zeros to the first blocks and then try to restore using sgdisk, this utility will complain about the mismatch of the backup and the main partition table.

If you have sgdisk installed anyway, you better use sgdisk --clear to clean out the GPT data. This doesn't initialize the tables to zero, but it does affect the end-of-disk backup copy as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.