From owner-freebsd-questions@FreeBSD.ORG Mon Feb 22 09:15:53 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 334AC1065670 for ; Mon, 22 Feb 2010 09:15:53 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx02.qsc.de (mx02.qsc.de [213.148.130.14]) by mx1.freebsd.org (Postfix) with ESMTP id CE2278FC25 for ; Mon, 22 Feb 2010 09:15:52 +0000 (UTC) Received: from r55.edvax.de (port-92-195-143-13.dynamic.qsc.de [92.195.143.13]) by mx02.qsc.de (Postfix) with ESMTP id D3ABC1D98E; Mon, 22 Feb 2010 10:15:49 +0100 (CET) Received: from r55.edvax.de (localhost [127.0.0.1]) by r55.edvax.de (8.14.2/8.14.2) with SMTP id o1M9Fns0001466; Mon, 22 Feb 2010 10:15:49 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Mon, 22 Feb 2010 10:15:48 +0100 From: Polytropon To: Aiza Message-Id: <20100222101548.8f2065b3.freebsd@edvax.de> In-Reply-To: <4B82416B.7050001@comclark.com> References: <4B82416B.7050001@comclark.com> Organization: EDVAX X-Mailer: Sylpheed 2.4.7 (GTK+ 2.12.1; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: freebsd-questions Subject: Re: Dump/restore to clone disk X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Polytropon List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Feb 2010 09:15:53 -0000 On Mon, 22 Feb 2010 16:33:47 +0800, Aiza wrote: > I have seen this posted in the questions archives to be > used to clone a active system hard drive to a > USB cabled hard drive. > > > > Prepare the target > #dd if=/dev/zero of=/dev/da0 count=2 > # fdisk -BI /dev/da0 > # bsdlabel -B -w da0s1 > # newfs –U /dev/da0s1a # / > # newfs -U /dev/da0s1d # /var > # newfs -U /dev/da0s1e # /tmp > # newfs -U /dev/da0s1f # /usr > > Mount target file system ‘a’ > # mount /dev/da0s1a /mnt > # cd /mnt > # dump -0Lauf - /dev/ad1s1a | restore -rf - > # cd / > # umount /mnt > > Mount target file system ‘d’ > # mount /dev/da0s1d /mnt > # cd /mnt > # dump -0Lauf - /dev/ad1s1d | restore -rf - > # cd / > # umount /mnt > > Mount target file system ‘e’ > # mount /dev/da0s1e /mnt > # cd /mnt > # dump -0Lauf - /dev/ad1s1e | restore -rf - > # cd / > # umount /mnt > > Mount target file system ‘f’ > # mount /dev/da0s1f /mnt > # cd /mnt > # dump -0Lauf - /dev/ad1s1f | restore -rf - > # cd / > # umount /mnt I'd like to suggest "successive" mounting of the partitions. E. g. as they are "nested" on the source disk, this can be done on the target disk, too. # mount /dev/ad1s1a /mnt # cd /mnt # dump -0 -f - /dev/ad0s1a | restore -r -f - # mount /dev/ad1s1e /mnt/tmp # cd /mnt/tmp # dump -0 -f - /dev/ad0s1e | restore -r -f - # mount /dev/ad1s1f /mnt/var # cd /mnt/var # dump -0 -f - /dev/ad0s1f | restore -r -f - # mount /dev/ad1s1g /mnt/usr # cd /mnt/usr # dump -0 -f - /dev/ad0s1g | restore -r -f - # mount /dev/ad1s1h /mnt/home # cd /mnt/home # dump -0 -f - /dev/ad0s1h | restore -r -f - And then: # cd / # umount /mnt/home # umount /mnt/usr # umount /mnt/var # umount /mnt/tmp # umount /mnt # sync # halt In the above example, transfer is going from ad0 to ad1. > I have questions about this method. > > What happened to swap? The fstab will be showing it as > the first file system on the hard drive slice. > Is something missing here? The swap partition does not need to be cloned. Furthermore, I doubt that it is the first partition on the disk, while it MAY be possible that it is the first entry in /etc/fstab. The root partition usually refers to partition a, while the swap partition refers to b. > What about the file system sizes. > Will the restored hard drive have the same > file system sizes as the source file system? The target partitions should be at least as big as the source partitions, and they will be filled up to the point the source partition has data, e. g. partition /usr is 20 GB and has 10 GB data, and it is dumped and restored to a new /usr partition with 30 GB space available, then this new partition will be occupied 1/3 (with 10 GB). > Is there some way to allocate larger file systems > on the target without using sysinstall to prepare > the target beforehand? Yes, "sade" is such a tool, as well as the usual method of using fdisk, bsdlabel, and newfs. > Is there some command to display > the file system allocation size? You can always use df -h for this, e. g. % df -h /var Filesystem Size Used Avail Capacity Mounted on /dev/ad0s1e 989M 384M 527M 42% /var THis should inspire you how to dimension the new partition. -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...