parted -ms /dev/sda print > sda.parted

This actually copies the layout to a file. If I want to restore the layout, what command should I give?


I think that it's not so straightforward to clone GPT table with parted otherwise you would write some simple wrapper which would parse the ouptut of the parted -ms /dev/sda print command and prepare related parted sub-commands to do it.

But there is available a GPT-aware fdisk tool called sgdisk which is part of the gdisk package on RHEL/CentOS/Ubuntu distros. With this one, it's easily doable:

# clone GPT table from /dev/sda to /dev/sdb
sgdisk -R=/dev/sdb /dev/sda

# make unique its GUID as it was cloned and is identical with /dev/sda
sgdisk -G /dev/sdb
| improve this answer | |
  • This seems to assume that the two disks are connected and working simultaneously. I get the feeling from the OP's question that the question is about copying the partitioning scheme from one disk to another, by way of a file and possibly separated by time. Could you expand your answer to perhaps indicate how one would do that using sgdisk? – user Oct 3 '13 at 7:43
  • sudo sgdisk --backup=sda.sgdisk /dev/sda – Hardbyte Aug 28 '15 at 8:48

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