Subject: Re: Tranferring a System
To: Ray Phillips <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: port-alpha
Date: 12/04/2001 21:43:49
> Is it possible to create a system disk by copying the contents of a
> disk that has NetBSD installed on it to another one?

Yes, with caveats.

> I thought the following scheme might work, but I'm not sure how cp
> will treat device files and sockets (and possibly other files I don't
> understand).

> [use cp -Rp to clone / and /usr, then run installboot]

I also think using cp will end up making multiple copies of hardlinked
files and filling in holes, and I'd worry about what it does with

If your devices are "the same" to a suitable level of detail, you can
copy the raw devices with dd (or moral equivalent - I'd actually use
blt, which overlaps I/O better).  If not, you may be able to copy the
filesystem partitions with dd and then fix up the label; this assumes
you don't mind using the same filesystem geometry info.  Failing that,
you probably will need to use some kind of archiver and dearchiver to
do the copy - dump and restore, or tar c and tar x; cpio and pax can
probably be made to do this too.  Some/most/all of these almost
certainly have interesting bugs (see Zwicky's torture-test work), but
unless you have near-pathological conditions in your filesystems you're
unlikely to trip over the bugs.  (Personally, I use my own tar, which
with the right options gets this sort of copy about as right as

> Perhaps there's a recognised standard way of doing this that I don't
> know about?

Most recommendations I've seen say to use dump and restore, or
sometimes tar.

> Can dd do it, even if the size of the partions on the two disks are
> not the same?

Provided the target partition is no smaller than the source, dd can do
it, but will produce a filesystem that doesn't use all of the target
partition.  Something like growfs or fsresize may be able to help with
that, but AFAIK none of those are "ready for prime time".  If you use
dd, you also have to be careful to do everything right with the label
and bootblock areas of the disk.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B