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
sudo sgdisk --load-backup=sda.sgdisk /dev/sda
– harperville Dec 07 '21 at 19:08