Howto Recover a Linux Partition after a Superblock corruption?
March 31, 2012 | Posted byA SuperBlock in Linux saves information about the File System like, the File System type, size, status etc. A File system cannot be mounted if a Superblock is corrupted. Corruption of superblock can occur due to various reasons like, abnormal shutdown due to power failure, virus infection, file system corruption etc.
When a Superblock is corrupted, you receive a ” can’t read superblock” error message while accessing the File System. For example, if you try to access a Linux ext3 partition say, /dev/sda3, you will receive the following message:
/dev/sda3: Input/output error mount: /dev/sda3: can’t read superblock
Linux ext3 file system automatically maintains a backup of superblock at various locations. In cases such as these, you have to restore a superblock from an alternate backup location to retrieve the data.
Note: You should unmount the partition before performing this task.
First, find / list the superblock locations of the file system /dev/sda3 (we are using sda3 as an example, your partition may be different)
# dumpe2fs /dev/sda3 | grep superblock
dumpe2fs 1.39 (29-May-2006)
Primary superblock at 1, Group descriptors at 2-2
Backup superblock at 8193, Group descriptors at 8194-8194
Backup superblock at 24577, Group descriptors at 24578-24578
Backup superblock at 40961, Group descriptors at 40962-40962
Backup superblock at 57345, Group descriptors at 57346-57346
Backup superblock at 73729, Group descriptors at 73730-73730
Now, check and repair (fsck) the file system with an alternate superblock #24577. BTW, try superblock from another location if one doesn’t work.
# fsck -b 24577 /dev/sda3 fsck 1.39 (29-May-2006) e2fsck 1.39 (29-May-2006) /dev/sda3 was not cleanly unmounted, check forced. Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information Free blocks count wrong for group #0 (3553, counted=513). Fix<y>? yes
Free blocks count wrong for group #1 (7681, counted=5059). Fix<y>? yesFree blocks count wrong for group #19 (7939, counted=7697). Fix<y>? yes/boot: ***** FILE SYSTEM WAS MODIFIED ***** /boot: 35/50200 files (8.6% non-contiguous), 17906/200780 blocks
Now, mount the partition once the file system check is over:
# mount /dev/sda3 /mnt
Once the partition is mounted, you can retrieve the files from /mnt:
# mkdir backup # cd /mnt # cp filename /backup/
BTW, it is always good to keep a backup of your data instead of finding yourself in such situations.