Let's say you've a server running a software RAID setup with multiple HDDs or SSDs, but one of them fails. You've replaced the failed drive with a new working one, but how do you copy or clone the partition table so that you can restore service again?
Considering most RAID setups have identical partition structures on every drive, and you're using a UEFI system (or otherwise GPT partition style) then the answer is quite simple. Make sure you read and follow carefully, else you might destroy partition structure of working disks too!
First, we need to install sgdisk, the utility we'll use to clone the partition structure. On RHEL/yum distros run:
sudo yum install sgdisk -y
Or, for Debian or apt based distros run:
sudo apt-get install sgdisk -y
Once installed, assuming sdX is a working drive, and sdY is the newly replaced one, run:
sgdisk /dev/sdX -R /dev/sdY
So what we're doing is copying the partition structure from sdX, over to the new sdY drive. But, you'll need to ensure your GUIDs do not clash. To randomise the GUID of the new partitions you've just cloned, run:
sgdisk -G /dev/sdY
Again, the above assumes sdY is the new drive you've replaced. Now you should be able to recover your RAID array using mdadm, ZFS or whichever method you're using.