== Copying GPT partition tables from disk to disk There's a number of situations where you want to replicate partition tables from one disk to another disk; for example, if you are setting up mirroring or (more likely) replacing a dead disk in a mirrored setup with a new one. If you're using old fashioned MBR partitioning, the best tool for this is _sfdisk_ and it's done as follows: .pn prewrap on > sfdisk -d /dev/OLD | sfdisk /dev/NEW Under some situations you may need '_sfdisk -f_'. If you're using [[new, modern GPT partitioning LinuxGPTAndEFI]], the equivalent of _sfdisk_ is _sgdisk_. However it gets used somewhat differently and you need two operations: > sgdisk -R=/dev/NEW /dev/OLD > sgdisk -G /dev/NEW For obvious reasons you really, really don't want to accidentally flip the arguments. You need _sgdisk -G_ to update the new disk's partitions to have different GUIDs from the original disk, because GUIDs should be globally unique even if the partitioning is the same. The easiest way to see if your disks are using GPT or MBR partitioning is probably to run '_fdisk -l /dev/DISK_' and look at what the '_Disklabel type_' says. If it claims GPT partitioning, you can then run '_sgdisk -p /dev/DISK_' to see if _sgdisk_ likes the full GPT setup or if it reports problems. Alternately you can use '_gdisk -l /dev/DISK_' and pay careful attention to the '_Partition table scan_' results, but this option is actually kind of dangerous; under some situations _gdisk_ will stop to prompt you about what to do about 'corrupted' GPTs. Unfortunately _sgdisk_ lacks any fully supported way of dumping and saving a relatively generic dump of partition information; '_sgdisk -b_' explicitly creates something which the documentation says should not be restored on anything except the original disk. This is a hassle if you want to create a generic GPT based partitioning setup which you will exactly replicate on [[a whole fleet of disks ../solaris/ZFSFileserverSetupII]] (not that we use GPT partitioning on our new iSCSI backends, partly for this reason). (I suspect that in practice you can use '_sgdisk -b_' dumps for this even if it's not officially supported, but enhh. Don't forget to run '_sgdisk -G_' on everything afterwards.) (This is the kind of entry that I write so I have this information in a place where I can easily find it again.)