I recently had to copy the partition table of a 3TB disk in a situation where tools such as sfdisk could not be installed.
Since GPT table length is dependant on the number of partitions, you need to do some investigation.
In this case, it was a ‘QNAP’ server that had fdisk (no GPT support) and parted.
On a working drive, run
parted -ms /dev/sda print
Note the number of partitions.
Formula = (128*N)+1024
Where N is the number of partitions you have. In this case I had 4, so I end up with a value of 1536
dd if=/dev/sda of=GPT_TABLE bs=1 count=1536
You now have a backup of a valid partition table you can apply to another drive
dd if=GPT_TABLE of=/dev/sdb bs=1 count=1536
Once this was done, you can manually re-add the drive.
mdadm –manage /dev/md0 –add /dev/sdb3
If you are wondering how we determined the sd[a-z], we accomplished this through hot-swapping the drive to generate logs indicating the drive.
Now why this supposedly automated RAID product required this…