12

On a non GPT partition table I can do

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

But sfdisk doesn't support GPT partition tables. What can I use instead?

I'm looking for a one or two command solution, not just using GNU parted to output the partition sizes and then manually making them again.

don_crissti
  • 82,805
  • Good reference to this Q on AU as well: http://askubuntu.com/questions/57908/how-can-i-quickly-copy-a-gpt-partition-scheme-from-one-hard-drive-to-another – slm Feb 12 '15 at 06:21

1 Answers1

16

Install gdisk which is available from sourceforge as well as from the Ubuntu Universe repositories.

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 (be careful not to mix these up). 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.

slm
  • 369,824