This is something that I have done more than once unfortunately. But the good news is that as long as you don't write anything on the disk, you can easily recover the partitions and it's content with this nice tool: gpart
(not to be confused with gparted
)
In my case, I accidentally created a new msdos partition table on /dev/sdb, so what I had to do was run:
sudo gpart /dev/sdb
to run a scan on that disk and see if gpart
could find any data, and it did. It showed me 4 o 5 "guesses", the first of which was obviously correct because it was the only one with actual data (the others were all zeroes or other nonsense).
So after reading what were the possible actions to restore the partition table, I ran:
sudo gpart /dev/sdb -W /dev/sdb
and this means that I will (-W)rite the "guessed" table to the same device (/dev/sdb). After that it asked me which of the guesses I wanted to save, so I selected 1 for the first one, and then it was done and I was asked to reboot.
I did, and there were all my partitions with all the data intact, back to me.
Top comments (0)