Copying partitioning to new disk

balanga

Daemon

Reaction score: 101
Messages: 2,425

I'd like to copy the layout of partitions on one disk to several disks and wondered if anyone knew of a simple way to do this. I don't need to copy the contents of the partitions, just the size and type. I guess what I need is just a way of parsing the output from gpart show da0, but not sure how to do that...
 
OP
OP
B

balanga

Daemon

Reaction score: 101
Messages: 2,425

Many thanks for this. I would not have been able to work this out from the man page. An example, such as ours is very useful.

One question though... does the above also copy any bootcode installed on the source device?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 6,934
Messages: 28,872

I would not have been able to work this out from the man page. An example, such as ours is very useful.
The example is copied straight from the man page. Most man pages have an examples section at the end.

Code:
   Backup and Restore
     Create a backup of	the partition table from da0:

	   /sbin/gpart backup da0 > da0.backup

     Restore the partition table from the backup to da0:

	   /sbin/gpart restore -l da0 <	/mnt/da0.backup

     Clone the partition table from ada0 to ada1 and ada2:

	   /sbin/gpart backup ada0 | /sbin/gpart restore -F ada1 ada2
does the above also copy any bootcode installed on the source device?
No, only the partition table. The bootcode is not part of the partition table.
 
OP
OP
B

balanga

Daemon

Reaction score: 101
Messages: 2,425

Oops! Should have noticed, but didn't think that gpart would have such an option... I think I mentioned somewhere that it must have around 100 options and is not the easiest of commands to master.

I was hoping to be able to copy a device which was set up with the Grub loader installed to a new disk, but obviously missed something. I did manage to get Grub working on one device but have been unable to repeat the process, so thought copying the partition structure, formatting and copying the first two partitions and installing grub on the new partition, using instructions I had made would work, but I obviously missed something...
 
Top