Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Aug 1998 03:25:56 -0400 (EDT)
From:      CyberPeasant <djv@bedford.net>
To:        shawn@cpl.net (Shawn Ramsey)
Cc:        nbm@rucus.ru.ac.za, questions@FreeBSD.ORG
Subject:   Re: duplicate hard drive
Message-ID:  <199808300725.DAA29486@lucy.bedford.net>
In-Reply-To: <19980829234414.64051@cpl.net> from Shawn Ramsey at "Aug 29, 98 11:44:14 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
Shawn Ramsey wrote:
> > > I need to replace the boot drive on one of our servers... Is possible to
> > > easily make a duplicate copy(boot manager and all) ?? I recall this being
> > > discussed awhile back, but I dont remember the thread and can't seem to find
> > > it in the archives...
> > 
> > If they're _exactly_ the same drives, you can use dd.
> > 
> > dd if=/dev/wd0 of=/dev/wd1       (from wd0 to wd1)
> > 
> > You can set a blocksize too, but dd usually chooses a considerate setting.
> > 
> > Rather don't do this while either drive is mounted, which means doing it from
> > a floppy install, probably, else putting both drives in another machine.
> > 
> > If they're not the same drives, there are other ways of doing things, which
> > other people will be able to explain better than I.
> 
> They are not the same drive... the old is a 545m, and the new is about 2
> gig. Would love to hear any ideas, as i'd rather avoid having to
> reinstall...
> 

This here be Unix land, Dude. We don't cotton to that reinstall talk.


OK, first set up the new disk, most easily by using sysinstall's
slice/partition editors. For the sake of illustration, I'll assume
the old disk is wd0 and the new one, wd1. (Just start sysinstall
from /stand/sysinstall and pick "index" and go to partition editor).

After that, run newfs over the new disk's partitions:

	newfs wd1s1a
	newfs wd1s1d
	newfs wd1s1e
... whatever you have. Maybe sysinstall did it already.

Now we do the fun:

Assume that you have partitions wd0s1a on / wd0s1d on /var
and wd0s1e on /usr.


	mount wd1s1a /mnt
	cd /
	tar cplf - . | ( cd /mnt; tar xvpf - )
	umount /mnt

	mount wd1s1d /mnt
	cd /var
	tar cplf - . | (cd /mnt; tar xvpf - )
	umount /mnt

	mount wd1s1e /mnt
	cd /usr
	tar cplf - . | ( cd /mnt; tar xvpf - )
	umout /mnt

	cd

All done. This is the "Method of the Ancient Ones"

What you're doing is making a tar archive on standard output,
then piping that to a subshell that untars it. It's fairly efficient.
There's a way to do it with a single pass, but it would look hairy
the first time. Somebody else will tell you to use  cp -R but that's
newfangled and I have been bitten by it. There's a way with cpio, too,
but it has a way of hosing things. My things, anyway. Someone
will chime in with dump/restore, but that's snake oil. (I don't
understand it, in other words). The tar-with-pipe thing is pretty
versatile for all kinds of tree copying, and does the Right Thing
with symlinks, hard links, devices, permissions, ownerships and dates.

Now, if you're going to boot off that disk, remount wd1s1a on /mnt,
and edit /mnt/etc/fstab to get the new device names in there.

Now you'll ask me about booteasy. I dunno...

dave
-- 
             Su accion letal comienza en pocas horas

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?199808300725.DAA29486>