Hy, I accidentially overwrote the first 1M of my harddisk on linux (using dd). So, the partition-table is gone. I can still access all partition (except the first one) using /dev/sda2 (and so on), so the data is still there. I only need the partition boundaries to restore the table. How can I do this? The Linux-Kernel must still know them because all mount-points still work. fdisk -l /dev/sda doesn't work because it acctualy reads the partition table.

Thanks!

link|improve this question

what filesystems are you using...sometimes you can find the start and end of partitions based on filesystem markers...just a thought – aking1012 Dec 1 '10 at 20:38
feedback

2 Answers

up vote 1 down vote accepted

The extents of the partitions can be read from /sys/block/sda/sda1/start, /sys/block/sda/sda1/size and so on. The values are in sectors. Write down these values before doing anything else, especially rebooting.

Once you have the values, you can recreate the partitions with fdisk. Use the u command to switch the unit to sectors, then create the partitions by entering

  • n
  • primary/logical/extended
  • partition number (except for logical partitions: do them in order)
  • initial sector
  • + size in sectors
link|improve this answer
I found those sys-files and wrote the values down, but how do I recreate the partitions using fdisk? What do you mean by expert menu? Thanks! – theomega Dec 2 '10 at 13:32
@theomega: I meant the x “extra functionality (experts only)” menu, but in fact it's not needed, you just need to use the u command to switch to sectors. – Gilles Dec 2 '10 at 19:23
feedback

Personally, I would use testdisk running from the Trinity Rescue Kit CD. It's well documented. I don't know how to recover the overwritten area of that first partition, though.

Trinity Rescue Kit CD

testdisk wiki and download

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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