FUN WITH LINUX

Copy the partition table from one disk to another

16 December 2014

Sometimes it is neccessary to copy the partition-table of one disk to another. Mostly this is needed when a disk should be replaced on a software-raid-array. The method described here also works for GPT-Tables..

Backup the table of /dev/sda:
sgdisk --backup=table /dev/sda
Restore the table to the new disk:
sgdisk --load-backup=table /dev/sdb
Backup and Restore from /dev/sda to /dev/sdb in one command:
sgdisk -R /dev/sdb /dev/sda
Finally randomize the GUID of all partitions on the disk:
sgdisk -G /dev/sdb

Method for MBR-Tables

Copy table from /dev/sda to /dev/sdb:
sfdisk -d /dev/sda | sfdisk /dev/sdb
(Optional)If you don’t see the partitions, read it again:
sfdisk -R /dev/sdb
[ Linux  Sysadmin  Partitioning  ]
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 Unported License.

Copyright 2015-present Hoti