This is my own recipe to clone a Debian system on two hard disks. It can also be done via network connection (ssh) if the two disks are not in the same computer; it only need to setup the network connections by ifconfig
Boot on RescueCD
Shell
rescuecd docache |
If it can't find media (too long anwser), after the liveCD get up to a secure shell, try again using
Shell
exec /linuxrc |
Choose the French language by entering the value 16 or fr
Find origanal device
Find original device and list partition table
Shell
fdisk -l /dev/sda |
Mount it
Shell
mkdir /mnt/orig | |
mount /dev/sda1 /mnt/orig |
Find clone device and partition it
Shell
echo "n p 1 1 100G n p 2 4G t 2 83 w" | \ | |
sed 's/ /\n/g' | \ | |
fdisk /dev/sdb |
Format clone partitions
Shell
mkfs -t ext3 /dev/sdb1 | |
mkswap /dev/sdb2 |
Mount clone
Shell
mkdir /mnt/clone | |
mount /dev/sdb1 /mnt/clone |
Clone disk
Shell
rsync -va /mnt/orig/ mnt/clone |
Check that clone coresponds to original
Shell
ls /mnt/orig /mnt/clone |
Install grub
- for grub 1
Shell
grub-install --root-directory=/mnt/clone --recheck /dev/sdb
- for grub 2
Shell
Remove UUID reference in /boot/grub/grub.cfg by replacinggrub2-install --root-directory=/mnt/clone --recheck /dev/sdb
root=UUID=...
byroot=/dev/sda1
. After first boot, you will need to update grub2 configuration withupdate-grub2
Configure network interfaces
Shell
orig=1 | |
clone=2 | |
sed -i 's/\(172\.16\.0\.)'$orig'/\1'$clone'/' \ | |
/mnt/clone/etc/network/interfaces \ | |
/mnt/clone/etc/hosts | |
sed -i 's/\(blade-\)'$orig'/\1'$clone'/' \ | |
/mnt/clone/etc/hostname \ | |
/mnt/clone/etc/hosts | |
rm /mnt/clone/etc/udev/rules.d/70-persistent-net.rules |
Rebuild ssh keys
Shell
ssh-keygen -t dsa -f /mnt/clone/etc/ssh/ssh_host_dsa_key | |
ssh-keygen -t rsa -f /mnt/clone/etc/ssh/ssh_host_rsa_key |
Unmount disks
Shell
umount /mnt/orig | |
umount /mnt/clone |
Reboot clone blade