How to copy a GPT partition scheme from one hard drive to another?

On a non-GPT partition table you can do

sfdisk -d /dev/sda | sfdisk /dev/sdb.

But sfdisk doesn’t support GPT partition tables.
Then you shall make:

Install gdisk from repositories or source.
Then use the sgdisk command (man page here) like so

sgdisk -R=/dev/sdb /dev/sda
sgdisk -G /dev/sdb

The first command copies the partition table of sda to sdb.
The second command randomizes the GUID on the disk and all the partitions.
This is only necessary if the disks are to be used in the same machine, otherwise it’s unnecessary.

If you tried and it didn’t work. The solution is:

sgdisk --backup=table /dev/sda
sgdisk --load-backup=table /dev/sdb
sgdisk -G /dev/sdb
Scroll to top