How to duplicate a Linux PC or partition via network
Imagine you get the task to quickly set up a number of identical
workstations. Unfortunately either the available removable media (e.g.
CD) is too small or the imaging tool you use insists on not
recognizing your favourite file system type (esp. Ext3, XFS, JFS,
Reiser), or you want to keep the other individual partitions on your
target PC. Here's how to do with on-board tools.
Requirements:
- Two or more identical PCs that are supported by the
- Boot media (floppy or CD) that can handle the hardeware as well
as the wanted filesystems, my recommendations: Knoppix CD
(http://www.knoppix.org/)
and TRBT floppy (http://www.toms.net/rb/)
- Linux starting with GRUB in MBR
- Boot media with basic GRUB installed. A GRUB floppy can be
created using the command grub-floppy
- Network infrastructure for the PCs - a simple crosslink cable
often is enough.
- The netcat program - usually (e.g. Debian-Linux, RedHat-Linux)
it is called "nc", but some other distributions call it "netcat"
(SuSE).
Create the master:
- Install and configure the master PC (i.e. the PC to be imaged)
- Install and configure SSHD server and RSYNC on that master PC
Mirror to a new PC:
- Boot with independent media and configure the network
- Create Linux and swap partition(s) as on the master PC
- Mount the linux patition to a temp. mountpoint:
mount /dev/sda3 /mnt
- Copy the complete OS from the master to the client:
rsync -raz root@server:/ /mnt --exclude /sys/ --exclude /proc/
- Reboot with the GRUB boot medium and boot the (installed) OS:
- root (hd0,2)
- kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/sda3
- boot
- Change IP address (in /etc/sysconfig/network-scripts/ifcfg.eth0
or /etc/network/interfaces or similar) - and hostname in /etc/hosts
and /etc/hostname
- Install the correct bootloader:
grub-install /dev/sda