Linux – How to restore a saved partition table to another disk with parted

linuxpartedrestoretable-partitioning

OS: Ubuntu 10.04

I have saved my partition layout from sda and want to restore it to my new disk sdb. I have used the following command to save the layout, but how can i restore it to my new disk using parted?

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

Best Answer

I don't think you can do that although you could probably read the file and do it manually, it's an easy format to understand

BYT;
/dev/sda:120GB:scsi:512:512:msdos:ATA KINGSTON SV300S3:;
1:1049kB:500MB:499MB:ext4::boot;
2:500MB:120GB:120GB:::lvm;

If you still have sda in the system then there are other tools yopu can use

For non GPT disks sfdisk works

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

For GPT disks

sgdisk -R /dev/sdb /dev/sda
sgdisk -G /dev/sdb

The latter clones the partition table and then creates new GUIDs for the disk and it's partitions which is necessary if both disks will be used in the same system.