While testing the Dell OpenManage 6.2 update recently, the main ext3 filesystem superblock on a gpt partition was damaged by the CentOS 5.4 installer.
I did not ask the CentOS installer to touch the non-system partitions in any way, but it happened.
Fortunately, mke2fs writes superblock backups to each filesystem in case something bad happens.
e2fsck -b could be used to recover a superblock from a copy, but I found a friendlier tool …
I used an Open Source tool by Christophe GRENIER called TestDisk to scan for a backup superblock, and overwrote the bad superblock in about 30 seconds. Then I added the original mount label and mounted the filesystem:
# testdisk_static (or testdisk_static /log /dev/sdb) # parted /dev/sdb name 1 /data (works on gpt partition types) # mount -a # ls -l /data # tune2fs -l /dev/sdb1
TestDisk worked perfectly, even on a complex system with Perc 6i and Perc 5e RAID controllers with 4 TB partitions, but you must carefully read and navigate TestDisk’s menus, and actually write the new superblock to disk for each filesystem that was lost. TestDisk can also be used to recover files and preventively to save superblocks before an issue occurs.
There are versions of TestDisk for several operating systems, including Windows, Linux 2.4, Linux 2.6 and FreeBSD.
Note that parted also has a rescue mode for partitions:
(parted) help rescue rescue START END # rescue a lost partition near START and END
Other tools to look at when fixing linux filesystems include tune2fs and partprobe.
For deeper insight into ext2 and ext3 recovery, search for the excellent articles by Ted Ts’o.


