[Tfug] right way to clone in linux

Kramer Lee krameremark1 at gmail.com
Wed May 18 21:32:46 MST 2011


Well, there are a couple of ways with free software.

With what you have maybe you just need to make a partition bootable.

Anyway PartedMagic gives tools to do cloning, and maybe I don't know
the best way to use it, as usually someone else has figured out a
better way, but for the sake of giving one way to do it, here is what
I would do.

I would download partedmagic, and make a CD from the iso file.  Then I
would either put the drive to be copied and the drive to copy to
installed in the computer, or put the one to be copied to in a USB
case.  Then I would boot with partedmagic.  Then I would bring up the
partition editor from the icon, and look at both drives.  Maybe you
could fix it here by seeing what partition on the old drive that works
has as the boot partition, and then go to the copied to drive and make
that partition the boot partition too.  If it has grub on it, you
might have to do something else, especially if the partitions are not
the same number and in the same order on the copied to drive as the
copied from drive.  If the partition numbers are different, such and
the old drive ext3 linux bootable partition is /dev/sda3 but on the
copied to drive it is /dev/sdb4, grub is just going to stop and hang.
You might be able to fix that by mounting the copied-to drive's main
linux partition, the one with /boot/grub on it, and editing grub.conf
or menu.lst, whatever is the boot control file on the distro, and
modifying it to point to the right partition.  Well that is old grub.
I suppose you have grub 2, and that might be harder.  So I don't know
what to do there.

So I would just delete all the partitions on the copied-to drive, and
start from the beginning of the drive copying process.  Hopefully the
copied-to drive is the same size or larger than the copied from drive.

With all the partitions gone from the new drive, go to the listing of
the old drive and choose the first partition in the list, and click on
  copy.  Then go to the copy-to drive, which has no partitions, and
choose the drive and click on paste, and let it go till it is done.
Do this over again until all the partitions are copied.  You will have
to make an extended partition at the correct time during this process
to match the one on the old drive so that all the partition numbers
will match the old drive partition numbers.  Otherwise it gets a lot
more complicated.

Don't try to  copy the swap partition(s) as that doesn't seem to work
very well.  Just make new ones on the copy to drive when it is time to
"copy" those partitions.  When you get all the partitions over to the
copy to drive, then manage the flags and make the partition bootable
that is bootable on the old drive.  Then you should be able to shut
the computer down and replace the old drive and it should boot.

But it would be a lot easier just to boot from some Linux live CD (or
the partedmagic cd), and use dd if=/dev/sda of=/dev/sdb (make sure it
is actually sda that is the copied from drive and sdb is the vacant
drive or else it is all over anyway), and that should work.  If you
want to expand partitions you can do it later by booting from
partedmagic and manually expanding the partitions.  How many partition
do you have anyway?

I used to use Drive Copy to do this and it would either expand the
partitions automatically or let me set the sizes to some extent for
windows partitions, but linux copying didn't have as many options.
PartedMagic uses gparted.

I see that this method (and I don't want to spend hours trying to make
a very exact method that would work for everyone no matter their
distro or partition setup, because I probably can't do that anyway)
could help a person try to do this and use all the data on the
copy-from drive if any mistakes were made during the process.  But I
have done it many times, with only problems at first.

There is clonezilla too, and I have had some success in having it
actually clone drives, but I have had failures with that too and I
don't know why, so I usually do the longer more tedious procedure one
partition at a time because that works better for me.

So I don't know if that will help.  If you had another drive just for
backup, you could dd to that one and then copy the partitions from
that to the copy to drive, and not lose anything if you do it wrong
the first couple times.  I would really not like it if I accidentally
copied the blank drive to the full drive.  I don't remember doing that
but I remember worrying about it.

I have had errors during partition copies, and I have to do it again.

Hopefully that helps.




More information about the tfug mailing list