How can I quickly copy a GPT partition scheme from one hard drive to another?
Install gdisk which is available in the Ubuntu Universe repositories.
Then use the sgdisk
command (man page here) to replicate the partition table:
sgdisk /dev/sdX -R /dev/sdY
sgdisk -G /dev/sdY
The first command copies the partition table of sdX
to sdY
(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.
I tried and it didn't work for me. The solution that I found is:
sgdisk --backup=table /dev/sda
sgdisk --load-backup=table /dev/sdb
sgdisk -G /dev/sdb
dd if=/dev/sda of=GPT_TABLE bs=1 count=A
dd if=GPT_TABLE of=/dev/sdb bs=1 count=A
partprobe /dev/sdb
where A is:
A=(128*B)+1024
B=parted -ms /dev/sda print |tail -1|cut -b1