Date: Thu, 27 Jun 2002 21:46:32 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: "Justin L.Boss" <jlboss@cox.net> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: copy one drive to another Message-ID: <20020627204632.GA5504@happy-idiot-talk.infracaninophi> In-Reply-To: <20020627155149.UUAV29627.lakemtao01.cox.net@smtp.east.cox.net> References: <20020627155149.UUAV29627.lakemtao01.cox.net@smtp.east.cox.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jun 27, 2002 at 11:51:49AM -0400, Justin L.Boss wrote:
> i'm trying to copy one drive to another. The drives are not the same
> size, so i'm trying to decide which would be the best way to do it.
You want to copy the contents of disk ad0 onto disk ad1
> dd if=/dev/ad0 of=/dev/ad1
This can only ever work if ad1 is the same size or bigger than ad0.
The filesystems you create on ad1 will be exactly the same size as the
original on ad0, so if ad1 is bigger you will waste some space.
The great advantage of using dd(1) is that you should be able to copy
foreign filesystems, even if they are unmountable under FreeBSD.
> dump -0 -f /dev/ad1 /dev/ad0
This is probably the best approach, although it's a bit more complex
than you've indicated.
First of all, dump works on file systems, not disk devices. You
should create disk slices, partitions and filesystems on ad1 to match
the originals on ad0 (ie. of sufficient size to contain all the data
you're copying over). You can use fdisk(8) to create slices,
disklabel(8) to generate partitions and newfs(8) to build filesystems
on those partitions. Or you can use /stand/sysinstall to do the whole
setup.
Now, for the actual copying. Copy each filesystem in turn, by piping
the output of dump(8) into restore(8). You need to mount the target
filesystems before you do the restore:
eg.
newfs /dev/ad1s1a
mount /dev/ad1s1a /mnt
cd /mnt
dump -0 -f - /dev/ad0s1a | restore -rf -
umount /mnt
> tar -cf /dev/ad1 /
tar(1) can be used as an alternative. Again, you're going to be
copying filesystems rather than the whole disk. Prepare pristine new
file systems on /dev/ad1 as for the dump/restore method. Assuming,
for example, that you've mounted your /usr partition on /dev/ad0s1f,
and you want to copy it over to /dev/ad1s1f:
newfs /dev/ad1s1f
mount /dev/ad1s1f /mnt
cd /usr
tar -lcf - . | ( cd /mnt ; tar -cvpf - )
umount /mnt
Some general remarks: dump/restore will give you the most faithful
copy of your data. Be careful if using tar(1) that you don't
accidentally include the target directory into the source of what
you're copying, or you'll end up with a huge mess. Use the -l flag to
limit the copy to one partition.
There's no point trying to copy swap areas by these means: it won't
work. Just mark the partition as swap using disklabel(8).
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks
Savill Way
Tel: +44 1628 476614 Marlow
Fax: +44 0870 0522645 Bucks., SL7 1TH UK
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020627204632.GA5504>
