I would like to mirror one drive's partition table, that is, have exactly the same partition on both sda and sdb. I have heard that one of the fdisk utilities can export a partition table into a file, and that file can be read back into another drive, but I can't seem to find this in the manuals.
Can someone help?
To summarize: I want to have the exact same partitions on both drives, same labels, same filesystem types, and same sizes. The data on the drive does not matter, I just want the partition table.
sfdisk -d dumps the partition table and throws it to stdout. This is being piped to sfdisk /dev/sdb with the --force, and so being written to /dev/sdb.
You can use
dd
to copy the Master Boot Record (MBR) from one device to another (or to a file). For example, copying the MBR fromsda
tosdb
would be done withThe flags are
The MBR contains the partition table for the four primary partitions, so this solution alone will not copy the definition for the extended partitions.
Wikipedia has good articles describing master boot records and extended boot records, explaining their relation to each other and their disk format.
Note: This solution is possibly only valid for MS-DOS, Microsoft Windows and Linux on PC compatible systems.