Cloning a disk with dd

I am trying to clone a drive. My Linux system is Centos 4.8. Sda contains everything except home and opt. Sda has bearing problems on startup. It warms up and works fine, but obviously it is not trustworthy. So I got an exact model to replace it. I put sda in tray one and the new drive, unformatted in tray 2. I used knoppix 6.2 to boot the machine, dismounted both drives and then typed dd if=/dev/sda of=/dev/sdb bs=1M

Eventually I get an I/O error, but 113 gb copied. Fdisk indicates the disk is partioned and sized exactly like the original, but it will not boot with the new disk. What am I doing wrong?
2 answers Last reply
More about cloning disk
  1. Assuming your disk size is 113GB then I would suspect the copy went OK. (You don't actually say whether all the data appears to have copied.) A possible cause of the problem is that most modern distributions use the disk id rather than the device name for booting and mounting, so you may need to change this in /boot/menu/menu.lst /etc/fstab. (I don't think dd preserves the disk id.) I had exactly this problem last time I cloned a Linux disk.

    The easiest thing to do is to use the knoppix boot again, mount the root partition on the copy and check these files. If there are references to a long string of numbers, rather then /dev/sda1, etc., in these files then change them to /dev/sda1 (or the appropriate partiton number) and try again.

    Failing that, let us know the exact sequence of messages that you get when trying to boot from the drive.
  2. That sounds like excellent advice and I will try that-mike
Ask a new question