If the hardware is similar enough, especially same HD device (e.g.
/dev/sda) then cloning can be done with
dd ( or CloneZilla). After copying the full disc (including bootsector) you should be able to boot the new system.
If there are changes in hardware that preclude a partition to partition copy, or if you want to change filesystem types, then you can copy the files of the various partitions to new partitions that are formatted on the target. But in order to allow to boot that system you need to make sure that
/etc/fstab is correct (changing
/dev/). You also need to
chroot to the new disc and both do an
update-grub to update the boot record and
/boot/grub/grub.cfg on the target.
If you need to clone at the file level, check if your old install is using
LABEL= entries in
/boot/grub/grub.cfg in that case just create the filesystems on the target with the same UUID resp. LABEL (e.g. mkfs.ext4 -U ...
andmkfs.ext4 -L ). If you are (still) using
/dev/... entries then consider changing those, if possible, before cloning (with the risk of breaking the old system), or try to make sure the devices are the same.
fstab are correct after the clone should be the mayor focus, without a bootable target system you cannot do much. The other things you need to watch out for, especially if the clone and the original are operating at the same time:
- fixed IP addresses
- software provided MAC addresses, resulting in DHCP request from different machines with the same MAC address
- ssh host-keys being the same for different IP addresses (remove
/etc/ssh/ssh_host_*_key* on the target).
I often found it much more easy, if moving to new hardware and I just wanted to be able to boot the old software, to install a new distribution and copy the old data to a new partition, and let the new distribution's
grub2 take care of generating the appropriate grub entries. That
only left doing the
fstab, and no hassle of re-booting from CD (or nowadays USB) to get the target system to work if there is an
/etc/fstab entry problem on the "cloned" system.