Checklist for 1:1 clone of a Debian system
When cloning a Linux/Debian system 1:1 you should have a checklist of what’s important to change on the cloned system.
For cloning I use the grml Linux Live-CD of course (the following tips are part of grml-tips as well). To create a 1:1 clone I boot grml on the systems (usually using the ssh=password bootoption to be able to access the system remotely as well) and use something like:
Listener: # nc -vlp 30000 > /dev/sda1 Source: # dd if=/dev/sda1 bs=$VALUE | nc -vq 0 $IP_OF_LISTENER 30000
When I have to leave the place where the clone process is running and if the CD-ROM doesn’t reinsert CDs on reboot automatically (usually that’s the case for server systems) I can use my remote-reboot procedure via ssh later on like:
eject &>/dev/null umount -l /cdrom eject /dev/cdrom echo b > /proc/sysrq-trigger
But stop: before executing the last steps to reboot the server you should take care of a few important steps, otherwise rebooting might fail and you won’t be able to login via SSH. ;-) That’s my personal checklist:
- Using LVM? If you want to rename any devices using vgrename/lvrename do not forget to adjust entries in /etc/fstab, lilo/grub,…
- Check that labels/UUID/… for stable devices inside your configuration path (bootloader config, /etc/fstab, /etc/udev/*,…) match with the present setup (of course that’s especially important if you change any labels/UUIDs/… on your box after cloning)
- Using udev, right? Do not forget to adjust any statically configured network interfaces as well – check out /etc/udev/rules.d/z25_persistent-net.rules and /lib/udev/write_net_rules (that’s probably the most common and serious pitfall when cloning systems BTW)
- Make sure to configure your network setup accordingly (using /etc/network/interfaces)
- Do you use any kernel modules on one host you don’t want to use on the other one? Check blacklisting, configuration,… in /etc/modprobe.d/ and /etc/modules.
- And last but not least: if you change any of the "core files" (see above bullets to get an idea what I’m talking about) make sure to rebuild your initrd (executing ‘update-initramfs -c -t -k $KERNEL_VERSION’), and when using lilo don’t forget to execute lilo as well :-)
Tip: I highly recommend the use of a version controll system for maintaining /etc, for example etckeeper and mercurial should do the job for you.
December 17th, 2007 at 17:30
instead of taking nc you can use udp-sender/receiver and have a fully fletched imaging system, if you’ve got plenty of processing power on the clients one may choose to pipe the output of dd through the compressing program of your choice [gzip|bzip2] choose which applies, have it working here with 40 clients (intel core2 duo), only bottleneck is the harddisk ;) have phun, epsil0n