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 cloned this drive about 6 months ago using dd. Today the partition tables got corrupted. What can I do to restore them using the old drive? I'm currently scanning for lost partitions using testdisk to see if it can fix it without bringing out the other one. It's just one partition, but it currently thinks it's EFI GPT or something. I don't know how to mark that it's ext4.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

PLEASE BACK UP BEFORE YOU TRY THIS - I have not tried it, and it could make things worse.

To backup the MBR which contains the partition table (and is easy to do)

dd if=/dev/sourcedisk of=target.file bs=512 count=1

Similarly to restore

dd if=target file of=/dev/targetdisk bs=512 count=1

This will copy the first 512 bytes onto the new disk - which provides includes inter-alia the partition table.

bs=block size, so take the first 512 bytes. count=1 take 1 block only, ie the first one.

There is an interesting post here with more in depth and alternatives to be more selective of what you back up and restore.

share|improve this answer
add comment

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.