From owner-freebsd-questions@FreeBSD.ORG Sun Mar 12 03:06:02 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 676C716A402 for ; Sun, 12 Mar 2006 03:06:02 +0000 (GMT) (envelope-from kdk@daleco.biz) Received: from ezekiel.daleco.biz (southernuniform.com [66.76.92.18]) by mx1.FreeBSD.org (Postfix) with ESMTP id A6A0A43D45 for ; Sun, 12 Mar 2006 03:05:58 +0000 (GMT) (envelope-from kdk@daleco.biz) Received: from [192.168.2.2] ([69.27.149.254]) by ezekiel.daleco.biz (8.13.4/8.13.1) with ESMTP id k2C34phB084787; Sat, 11 Mar 2006 21:05:12 -0600 (CST) (envelope-from kdk@daleco.biz) Message-ID: <44138FC9.30900@daleco.biz> Date: Sat, 11 Mar 2006 21:04:41 -0600 From: Kevin Kinsey User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20060127 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Grant Peel References: <001901c64517$9d891950$6701a8c0@GRANT> In-Reply-To: <001901c64517$9d891950$6701a8c0@GRANT> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: dd - cloning a disk. X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Mar 2006 03:06:02 -0000 Grant Peel wrote: > Hi all, > > Here is a simple (I think!) question for the I/O savy among you: > > If I had two identical disks, say, 73 GB Seagate 10K SCSIs, one > completely > operational fully setup FreeBSD with all the trimmings, and the other > blank, > or perhaps loaded but no longer usable, is 'dd' and appropriate tool to > completely clone the Good disk to the not so good disk....therefor > making the second disk identical to the first? Bootable and all? > > -Grant Hi, Grant: Yes, dd, will copy/clone a disk. There was a fairly long, good thread on this subject on this list sometime in the last 3-5 weeks. Giorgios Keramidas commented that "dd" was too slow for his tastes and suggested dump and restore for this type of work. Now, I'm no expert at fdisk and bsdlabel scripting, but here's a plan I adopted as a result of that thread. It includes manual labor via the sysinstall front end to fdisk and bsdlabel, and then is "automagic". 1. Set up the hardware--- I'm assuming extant drive on primary IDE master and new drive as same channel slave. 2. Run sysinstall as root, choose "Configure (Post Install Configuration) and run Fdisk. Dedicate the entire new disk and set it bootable. Write out the changes with, um "W", isn't it (IIRC).... 3. Exit sysinstall and then start it up again. Run the "disk label editor" and set up partitions of a sufficient size for the clone procedure (generally, same size or larger; in a pinch, could be smaller than the original partition but, obviously, must be large enough for the data on the original partition). Write out the changes, exist sysinstall. 4. Run this script (edit it to reflect your actual layout): #!/bin/sh mkdir -p /1 mkdir -p /2 mkdir -p /3 mount /dev/ad1s1a /1 mount /dev/ad1s1d /2 mount /dev/ad1s1e /3 dump -0 -a -L -f - / | ( cd /1 ; restore -ruvf - ) dump -0 -a -L -f - /var | ( cd /2 ; restore -ruvf - ) dump -0 -a -L -f - /usr | ( cd /3 ; restore -ruvf - ) Quick, easy, fast. Probably someone with a better handle on fdisk/bsdlabel could script steps 2-3 above. And, with thought, #4 could be improved, too. But, it is faster. Basically, I'm thinking this: A. With the "dd" approach, you don't need to know anything about the extant filesystem's layout. B. But, if you use dump | restore, you trade a little foreknowledge of the extant filesystem's layout for flexibility (disk doesn't have to be identical); and speed (the only thing copied is the data, not the blank space, and from a filesystem viewpoint instead of block level copying). We've used this successfully to create a number of disks for "cheap" workstations at a client of ours---as a result, they have plenty of stations available with almost no time spent in "tweaking" the installation other than hostname and interface configuration in rc.conf. YMMV, and all that. HTH, (or at least provides another perspective). Kevin Kinsey -- My doctorate's in Literature, but it seems like a pretty good pulse to me.