Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
The util-linux partitioning tools (including sfdisk) were rewritten to include GPT support for util-linux 2.26. sfdisk differs from gdisk in that it doesn't support putting a small boot partition before 1MiB, though, so it choked on my config. (bug reported upstream already.) –  Peter Cordes Mar 1 at 17:01

4 Answers 4

up vote 55 down vote accepted

Install gdisk which is available in the Ubuntu Universe repositories.

Then use the sgdisk command (man page here) to replicate the partition table:

sgdisk -R /dev/sdY /dev/sdX
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.

share|improve this answer
This information is golden for anyone who wants to replace a failed RAID-1 disk. Thanks! –  Christian Oct 22 '12 at 14:30
@Christian Yep, that's what I used it for. –  Kris Harper Oct 22 '12 at 14:42
According to the manual this also supports MBR-only disks (sgdisk auto-converts on load), which is pretty great. –  Tobu Mar 9 '13 at 23:11
Before making any destructive changes, be sure to take a backup with: sgdisk --backup=/some/safe/location/sdX.gpt /dev/sdX and sgdisk --backup=/some/safe/location/sdY.gpt /dev/sdY –  Michael Kropat Dec 1 '14 at 6:02
This command works but it should be noted that the drive ordering is backwards in the example. A more obvious way to write this is sgdisk /dev/sdX -R /dev/sdY –  Geoffrey Jan 7 at 0:26

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
share|improve this answer
I found this solution is better, because it can work with non-GPT. I also change the last command to: sgdisk -g /dev/sdb –  Locke Dec 7 '13 at 9:09
The above does work, you need to pay attention to the fact that the example is a little backwards (although correct). sgdisk /dev/sdX -R /dev/sdY is more obvious. –  Geoffrey Jan 7 at 0:27
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:

B=parted -ms /dev/sda print |tail -1|cut -b1
share|improve this answer

I just tried replication with sgdisk and it works just fine - you just have to follow readline syntax rules:

   sgdisk --replicate=/dev/target /dev/source


   sgdisk -R/dev/target /dev/source

and everything works.

share|improve this answer
This is exactly what my answer says. –  Kris Harper Nov 5 '13 at 21:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.