Input output errors on a data partition

Unexpectedly got input output errors on a data partition. Most recent was backup about 6 months old (sigh).

I recovered most of the data by following this Ubuntu thread: http://ubuntuforums.org/archive/index.php/t-1245536.html

The part that saved me consisted of two steps:

  1. su; mkfs.ext4 -n /dev/sdx1
  2. e2fsck -f -b 32768 -y /dev/sdx1

32768 refers to the newly written superblock after having executed (1)

# mkfs.ext4 -n /dev/sdx1
mke2fs 1.42.6 (21-Sep-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
4808704 inodes, 19233813 blocks
961690 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
587 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
    4096000, 7962624, 11239424

Just like the poster, I needed the -y option because there were too many errors, so fixing should be the default option. Read the full thread for more information (this pointer was also interesting, but just didn't go far enough). Obviously you should use your own device, not /dev/sdx1 (check /etc/fstab and the output of su; fdisk -l).

NB A problem like this is of course a warning that your hard disk may be nearly dead, and should be replaced!