How to backup and restore GPT header and table / MBR on mac ?

Mac OS X systems use GPT based partition table on a physical hard disk. Sometimes due to disk errors or any other reasons the GPT partition table may get corrupt. In such situations the operating systems restore the GPT table from the secondary GPT header lying at the end of the disk. There are some situations when secondary header is also corrupt then it is very hard to recover the partition schema of that disk. We can take a backup of the GPT table from the mac in the form a device file and can use it to restore back onto disk. 

The GPT table and header of the disk can be backed-up as below :

         $ sudo dd if=/dev/disk0 of=GPT bs=512 count=34

The GPT table and header of the disk can be restored as below :

         $ sudo dd if=GPT of=/dev/disk0 bs=512 count=34

Similarly for MBR disks back up can be taken as below:

         $ dd if=/dev/disk0 of=MBR bs=512 count=1

MBR header can be restored back as :

         $ dd if=MBR of=/dev/disk0


Popular posts from this blog

How to disable USB ports on Mac OS X Mavericks, Yosemite or El Capitan ?

How to enable root login in gnome on Debian 6 or 7