Cloning FreeBSD installations?

Malcolm Kay malcolm.kay at internode.on.net
Thu Oct 30 05:10:51 PST 2003


On Thu, 30 Oct 2003 19:49, a at jenisch.at wrote:
> Hi,
>
> I'm about to set up several identical machines (identical hardware
> both in terms of processor, harddisk, LAN etc.) with FreeBSD 4.9. The
> only difference between these machines is they're running under
> different IP-addresses - all the rest (kernel, software,...) should be
> identical.
>

I suggest you probably also want different host names.
I had a similar task to create clones of a machine 'phoenix00'
as machines 'phoenix01' to 'phoenix14' for which I wrote (and used)
the attached script.

The original machine had ip 192.168.3.237 and the clones were to have ip
addresses in the range 192.168.3.211 to 192.168.3.249

The original system is in partitions ad0s1a, ad0s1e, ad0s1f and ads1g with
swap on ad01b.

To use the script attach the (identical) drive to as ad1 to 'phoenix00'
and call the script (as root):-
(There is no secondary IDE port on the machines in question which might have 
been somewhat faster)
 
# ./clone.sh ip mach
where ip is the last group for the required ip and mach is the numeric part
of the clone host name 'phoenixNN'.

The script copies the MBR and disklabel from ad0 to ad1 and then creates the 
file systems and copies data with dump and restore. The cloned configuration
file /etc/rc.conf is edited using 'sed' to update the ip address and hostname.

Plug the cloned disk into the new machine (as ad0) and it should boot without 
problems (remembering to fix master/slave links on the disk).

Adapt, use and enjoy.

> In order to keep installation effort at a minimum I'm looking for a
> way to "clone" FreeBSD installations from one machine to another.
>
> To be specific:
>
> o) Is there a way to clone one machine to another one "over the net",
> i.e. by writing an image file from one machine to a server and then
> setting up the other machines from that image?
>

Probably but would need more preparatory work.

> o) Is there a way to clone FreeBSD installations by copying the entire
> FreeBSD slice to another drive (I thought about installing the
> harddisks of the other machines in the master machines and then
> copying the installtion) (Is "Knoppix" capable of doing this?)
>

I don't know Knoppix but if you have large disks any literal byte to byte 
disk copying will take quite a while. Should also be possible with dd
but if the source is mounted rw at the time the copy will not appear to be 
clean when booted in the new machine.


Malcolm Kay


More information about the freebsd-questions mailing list