Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've got an 8.04 Mythbuntu installation I need to clone to another disk. Unfortunately the disk it's on has a few errors, so dd aborts when I try the usual

dd if=/dev/sda of=/dev/sdb

Last night I discovered the conv=sync,noerror option for dd (and it reported 2 errors), but when the transfer was done the disk wouldn't boot. I had gparted check the disk (it ran "e2fsck -f -y -v /dev/sdb1"), and after a few minutes it reported an error and crashed - I couldn't get the error info because the screen was frozen. I then tried it again on just the boot partition (instead of the entire disk) and got the same results. Tonight I'll try dd one more time and check the disk outside of gparted so I'll (hopefully) at least see any error messages.

But my question is: Is there another way to clone this drive (including keeping the same UUID) besides dd? I wouldn't mind copying it file-by-file (and that way I could see if there are any files corrupted by the errors dd sees), but I'm not sure how to do that and keep it bootable and keep the same UUID. I know I could reinstall from scratch, but after all the customization and tweaking I've done that is a very last resort.

share|improve this question

3 Answers 3

Hm cloning a broken disk is probably never a good idea. You can basically copy all the files to another disk and try to re-setup the mbr. What do you need to keep the UUID for? Reinstalling shouldn't be that hard, as long as you mainly tweaked in your home folder (or know what you changed outside of it) and may still be the cleanest sollution (and you will get the most recent software)

share|improve this answer
1  
+1 For recommending reinstall rather then clone –  Diago Aug 7 '09 at 14:00
    
I don't dispute that reinstall is the "ideal" solution. But for me, it's not risk-free as it seems. With my limited skills I may not be able to recreate all the features and functionality I have now. And it will take an enormous amount of time to do it. So if there's a way to clone the disk with the disk error that dd sees (but I have never run into in 1 year of operation), there's a very good chance I'll have a fine system. If not, I'll reinstall. Want same UUID because a lot of installed software seems to fail if it changes (I tried a simple file copy a while back and this bit me). –  Fred Hamilton Aug 7 '09 at 17:47
    
Yepp I get your point. Just can tell you about what I learned about the whole thing and with growing experience it just got easier to do all the tweaking because you actually knew what you where doing (and not just randomly succeeded). If you just want a running system your approach might be better (though more risky because you still have the errors and system might randomly break for no ovious reason - kind of like broken RAM) and you could learn a lot by actually redoing it all (mine got better every time I did this) –  Daff Aug 7 '09 at 23:33
    
I see your point as well. For me it's mostly a time thing - this is my MythTV (Tivo equivalent) and my wife wants to see 99.9% uptime :-). So I'd like to transplant the working system to a healthy drive immediately, then I could breathe easier and I'd be free to do a fresh build at a more leisurely pace (it took me months to get this system to the state its in). I just ran "fsck -f" on the boot partition with the error on it and it read back completely clean. So I think the risk of a problem is even lower than I thought before, but I still can't find a way to clone/copy the drive! –  Fred Hamilton Aug 8 '09 at 19:33
up vote 1 down vote accepted

The final solution turned out to be relatively simple (none of the dd solutions worked).

  1. Booted off of a 9.04 live CD with both my original problem drive (/dev/sdf) and the new drive I wanted to clone the original drive to (/dev/sde) attached.
  2. To make sure the disk was bootable, grub was installed, etc., I installed Ubuntu 9.04 on the new disk (sde). (There's probably a faster way to accomplish this but I knew this would do the trick.)
  3. Mounted sdf as disk-1, sde as disk-2
  4. Deleted all the files off the new install on disk-2
  5. Mounted sdf as disk-1, sde as disk-2
  6. sudo cp -a /media/disk-1/* /media/disk-2 (copies all the files recursively and keeps attributes and permissions)
  7. sudo blkid (Gets list of the UUIDs of all the disks. Manually copy the UUID for the new (sde) partition to the clipboard)
  8. sudo gedit /boot/grub/menu.lst (Now change the UUIDs in the grub entries from the ones for sdf (old) to the ones for sde (new) by pasting in the previously copied UUID)
  9. Rebooted, and it worked! Hallelujah!
share|improve this answer

When plain dd fails you can try with dd_rescue instead, because dd_rescue does not abort on errors on the input file.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.