This is how I would do it, but unfortunately I don't have a second disk to test this out on:
- Install the (preferrably identical) harddrive for the clone in the machine that already has Linux installed and configured how you want it.
- Partition this drive using fdisk or cfdisk, the same way that the HD you want to clone is partitioned.
- Mount /boot if it is not already mounted.
- Mount / and /boot partitions of the clone drive (on say, /mnt/clone/ and /mnt/clone/boot
- Copy everything from / to /mnt/clone/ using the following commands:
- Copy eveything from /boot to /mnt/clone/boot using the following commands:
Code: Select all
# cd /boot
# cp -avx /boot /mnt/clone/boot/
- You should chroot into this new drive, so we can make sure that your bootloader is installed. Do it just like in the Install Docs:
Code: Select all
# chroot /bin/bash /mnt/clone/
# env-update
# . /etc/profile
- Install your bootloader of choice, making sure that it installs itself on /dev/hdx (whatever the clone drive happens to be). Look in the install docs for this.
- Exit the chroot, and shutdown your machine to disconnect the clone HD.
- Install the clone HD into the clone machine, and boot and see if it works!
The cp options above tell cp to archive (-a), to be verbose (-v), and to only recurse in the current filesystem (-x). The archive command preserves symbolic links (so they refer to files in the clone filesystem, not the original filesystem), copies the source directory recursively, and preserves file permissions, owner, groups, setuid, setgid, and timestamps
Again, I want to stress that this is completely off the top of my head, and is something you only want to do once, or at most infrequently. You could probably use the dump command, but I'm not really familiar with it.