How to recover ext4 from GPT partitioned disk

Hard drive sizes had increased dramatically in last several years, but block device drivers are still outdated. For hard drives more than 1TB currently seems to be an advantage to use GPT instead of legacy MBR partition table. You can see more details at http://en.wikipedia.org/wiki/GUID_Partition_Table .

One of the inevitable disadvantage of GPT is the possibility of corruption by using outdated partition editor like cfdisk, or other disk tools, even without any intention to modify the partition.

It happened recently on one 1.5TB WD Caviar Green with GPT and one ext4 partition full of data.

I tried to repair the superblock using tools like:

  • For partition listing:

fdisk -l

  • To check the filesystem:

fsck.ext4 -v /dev/xxx

  • To list where the superblock backups are stored:

mke2fs -n /dev/xxx

  • To restore superblock from backup:

e2fsck -b block_number /dev/xxx

My story was completly different. It does not work this time. Could work fine if you have a traditional MBR partition table. In case of GPT, TestDisk was the magic software that saved my disk. Read documentation first, think carefully what do you want to do and you have a chance to recover 100% your disk. One note here. TestDisk has an “invasive mode” and a “recovery mode”. In recovery mode you can save a specific file or a disk image. This is not distructive. But you must have a spare disk to save the data. In my case I simply fixed the GPT table and I was lucky. That is why I recommend you to fully read the documentation from TestDisk.

http://www.cgsecurity.org/wiki/TestDisk

 

Leave a Comment