Recovering from "failure reading sector"

7,764

Solution 1

The problem seems to be with the superblock of partition /dev/sda1. Selected links on the superblock are listed below.

You are in a good position, since the partition of most interest to you (/dev/sda3) seems ok. So you would:

  1. Backup contents of /dev/sda3 (the essential part).

  2. Get back to normal by

    2.1. Try repairing your system.

    2.2. Reinstalling from scratch and recovering your backup.

For step 1, you could well work with the remaining unformatted 500Gb as the backup storage (it should be ok), after booting from a Live CD/USB and suitably formatting the space. Nevertheless, to be on the safe side, you could get an external disk (recommended). The extra space actually needed is not ~380Gb, but it depends on the amount of data to be backed up from /dev/sda3. Even though it is likely irrelevant, as an external disk (or your new partition) will likely have 500Gb+, I mention this finer figure just in case it makes a difference to you.

Once you have booted in your new system, you could mount /dev/sda3, and backup your data. Use rsync, or tar to copy a directory structure, e.g.

For step 2.2, you surely know how to do it.

For step 2.1, this is an oft-quoted guide.

PS: Next time you face a "The whole saga ..."-type of problem (or others), remember The magic SysRq key (mostly REISUB).

PS2: Here, a warning on the use of TestDisk. Although it most often works like a charm.


On the superblock:

Solution 2

Buy a new disk and use ddrescue to copy the partitions. Booting from new disk after that will not experience sector errors, any FS errors can be fixed with fsck. Boot problems will be fixable using GRUB.

Share:
7,764

Related videos on Youtube

Sundar R
Author by

Sundar R

#SOreadytohelp

Updated on September 18, 2022

Comments

  • Sundar R
    Sundar R almost 2 years

    When I boot up my laptop (with only opensuse installed, no other OS on it), I'm greeted with error: failure reading sector 0x802 from 'hd0'. and get put into GRUB rescue prompt.

    I used the original installation USB to boot up a rescue Linux system. This is fdisk - l output from the rescue shell (the disk is the 1TB HDD that arrived with the laptop, only half of it has been partitioned and in use): IMG-20200312-195659-1584025922398.jpg

    sda1 is the 30 GB partition with Opensuse in it, sda3 is a 350+ GB data partition. Trying fsck /dev/sda1 gives

    fsck.ext2: Input/output error while trying to open /dev/sda1
    
    The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem.
    

    This is followed by a suggestion to "try running e2fsck with an alternate superblock" (note: fsck on sda3 says "clean"). Running dumpe2fsck as suggested on the Opensuse wiki returns the same error message as above. I tried e2fsck -b <superblock> /dev/sda1 - with superblock as 8193 (said "Bad magic number in superblock"), and with superblock as 32768, which resulted in prompts to fix "Free blocks count", "Directories count", "Free inodes count" in many different groups (with a huge list of "Inode bitmap differences" in-between). But unfortunately, even the latter ultimately says "Error writing block 1 (Input/output error)" and doesn't fix the issue.

    The whole saga started when the OS hung mid shutdown, and (in an attempt to save battery life) I force killed it by long-pressing the power button. I have looked under the hood and there doesn't seem to be any cable issues (and the other partitions show up fine anyway). Losing the 30GB OS partition would be an inconvenience, but losing the 380 GB data partition would be a major setback I'd rather avoid. What are the next steps to recover from this error and make the disk usable again?

    • Tonny
      Tonny over 4 years
      Whatever you do.... Hookup an external harddrive (buy one if needed) and copy the data from your data-partition. Chances are this is the first indicator that the harddisk is dying. So get your data save ASAP.
    • Robert
      Robert over 4 years
      SSD or HDD? Check the SMART values using smartctl. Typically the only fix for a HDD with defects is a recent backup.
    • Attie
      Attie over 4 years
      As per @Tonny's recommendation, treat this disk as read only from now on - make no attempt to mount / repair a file system or write to it at all. Grab a second disk (or other storage) that can contain the entire capacity of sda, and then use ddrescue to make a complete image of sda in your larger storage. ddrescue can skip over failing blocks quickly to get as much of the data as possible, and then go back and fill in the problematic blocks by retrying over and over again.
    • harrymc
      harrymc over 4 years
      I would suggest following Attie's advice, even to the point of creating a replacement disk, since this one has an issue. After taking the backup try this HOWTO: Repair a broken Ext4 Superblock in Ubuntu.
    • dirkt
      dirkt over 4 years
      In additional to the other advice, after you've made a copy of your disk, and checked the SMART values and they turned out ok, try writing the damaged sector (e.g. with dd). This will cause the disk to allocate one of the "spare" sectors for this sector, and then you can use fsck to restore the superblock from the copy.
    • sancho.s ReinstateMonicaCellio
      sancho.s ReinstateMonicaCellio over 4 years
      Sundar, whenever you deal with this, please post feedback so we know what worked for you. Thanks.
  • harrymc
    harrymc over 4 years
    You do know that Monica has been reinstated via a confidential agreement?
  • sancho.s ReinstateMonicaCellio
    sancho.s ReinstateMonicaCellio over 4 years
    @harrymc - I have just read lightly about it. Still have to learn the details (whatever is public). I would of course change my username.