Subject: Re: Cloning /dev/wd0
To: None <collver1@attbi.com>
From: Frederick Bruckman <fredb@immanent.net>
List: netbsd-help
Date: 12/10/2002 09:28:08
On Tue, 10 Dec 2002 collver1@attbi.com wrote:

> On Tue, Dec 10, 2002 at 07:30:08AM -0700, Herb Peyerl wrote:
> > frankly, unless the disks are identical in geometry and size, I probably
> > wouldn't use 'dd' to mirror them.
>
> Someone told me it is possible that one disk will have a bad sector and
> cause dd to fail, giving another reason not to clone with dd.  What would
> be the best way to duplicate a disk?  I imagine that it could be a simple
> shell script (on i386) to:
> 	* use fdisk to read the partition table and write one
> 	* use installboot to make the new disk bootable
> 		(but how do you find the original boot configuration?)
> 	* use disklabel to read the disklabel, save to file
> 	* edit the disklabel file
> 	* use disklabel to write the new disklabel to the new disk
> 	* for each bsd filesystem in the disklabel
> 		* use dumpfs to read fs parameters
> 		* use newfs to create the fs on the new disk
> 		* use dump|restore to copy the filesystem

Is this an upgrade, or a backup? If an upgrade, you shouldn't care
much about the old file system's sizes and layouts. Just make the new
file systems whatever size is convenient. This would be, in fact, your
best opportunity to adjust the layouts and sizes. If it's supposed to
be for backup, you might look into RAID.

To make a disk bootable, you always run "installboot" last, after the
"restore".

Frederick