[CentOS] cloning drives

Les Mikesell lesmikesell at gmail.com
Fri Dec 2 19:24:55 UTC 2005


On Fri, 2005-12-02 at 11:39, lists wrote:
> Good day everyone - This maybe somewhat OT, but I was wondering if anyone can recommend a good tool for 
> cloning *nix drives. The one thing though is that I will be cloning a smaller drive than the destination drive and 
> would like to distribute the free space accordingly on the new drive.
> 
> Can anyone recommend anything?

The straightforward way to deal with size mismatches or different
filesystem types is to fdisk/mkfs/mkswap the new partitions yourself
then copy the contents over from the matching source partition using
any number of ways that preserve the attributes.  If the destination
is connected in the same box I usually use:
cd source_mount_point; cp --one-file-system -a . /dest_mount_point
but tar and rsync work as well.  You also need to either label
the partitions to match the old ones or fix what will be the new
/etc/fstab and /boot/grub/grub.conf to use device names for the
partitions instead of labels.  The last step is to run grub to
make the new drive bootable.  You can either hunt up the instructions
to install on a different drive or just move the drive to it's new
location, boot the Centos install CD with 'linux rescue' at the
boot prompt, "chroot /mnt/sysinstall" when it tells you, and run
grub-install from there.  Then exit (twice) to reboot.

An alternative that would probably work would be to boot the
source machine with the CD in rescue mode, use dd to copy the
source to target device, then expand the partition to use the
additional space and resize the filesystem.

-- 
  Les Mikesell
   lesmikesell at gmail.com





More information about the CentOS mailing list