0

Due to hardware problems, there are some Input/output errors. Some of my hard disk sectors are bad.

# find . -name 'cpp-service.zip'
find: ‘./.cache/chromium’: Input/output error
find: ‘./.config/chromium/ShaderCache/GPUCache’: Input/output error
find: ‘./.config/chromium/Safe Browsing’: Input/output error
find: ‘./.config/chromium/Subresource Filter/Unindexed Rules’: Input/output error
find: ‘./.config/chromium/CertificateRevocation’: Input/output error
find: ‘./.config/chromium/Crowd Deny’: Input/output error
find: ‘./.config/chromium/AutofillRegex’: Input/output error
find: ‘./.config/chromium/GrShaderCache/GPUCache’: Input/output error

Question

How can I mark the above files/folders having Input/output error as void? I mean, I intend to tell the filesystem to completely ignore the above files/folders. As if they don't exist. How can I do that?

Move

I cannot move them:

# mkdir ~/badblocks
# mv .cache/chromium ~/badblocks/
mv: cannot stat '.cache/chromium': Input/output error
Megidd
  • 1,519
  • 3
  • 32
  • 44

2 Answers2

1

I would recommend moving these files elsewhere, for instance, to /badblocks or something.

The reasoning for this is:

  • If you delete them, the bad blocks might get reused. So if you keep the files, the bad blocks are captured instead.
  • If you move the files and/or directory somewhere else, it allows the directory to be recreated. For things in .cache this happens automatically when the application needs it
  • By moving it to an out of the way directory (like /badblocks and chmod 700) it prevents most accidental access to the bad blocks
  • Accessing or even testing bad blocks on a spinning disk increases the chances of damaging neighboring blocks, so just moving them out of the way is somewhat safer
  • This disk is likely failing; you should be focusing on data recovery rather than repairing the disk. Moving bad blocks out of the way can make copying remaining files easier.

If your disk has enough bad blocks that you've run out of replacement blocks, it is failing and will likely not last much longer. Presumably, you are doing something about that already.

user10489
  • 5,834
  • 1
  • 10
  • 22
  • I cannot move them: `mv: cannot stat '.cache/chromium': Input/output error` – Megidd Dec 26 '21 at 15:56
  • Maybe the whole .cache directory is bad – user10489 Dec 26 '21 at 16:05
  • Moving the whole directory throws the same error: `# mv .cache ~/badblocks/ mv: cannot stat '.cache/mesa_shader_cache/f8/e1a29945d437fa558928bb2dc22e947cc26697': Input/output error` – Megidd Dec 26 '21 at 17:44
  • Hmm, I probably should have said you need to move it within the same filesystem. So if it is mounted on /home for instance, then you need to move to /home/badblocks/ – user10489 Dec 26 '21 at 21:02
1

If your file system is Ext3 or Ext4, you can run a file system check combined with a check for bad blocks, and any bad blocks will be excluded from future use:

e2fsck -c -f -k /path/to/device

-f will force a check, -c will check for bad blocks (double it to perform a non-destructive write test instead of the default read-only test), -k will keep any existing bad block information.

It will be simplest to run this from a recovery environment, e.g. from a bootable live system.

Note that a disk with bad blocks is reaching the end of its life and can no longer be trusted.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
  • My file system is `xfs` type. Do you know which tool should be used rather than `e2fsck`? – Megidd Dec 26 '21 at 17:53
  • 1
    XFS doesn’t provide a way to track bad blocks in the file system; it came from systems where drives would do so themselves (workstations with SCSI drives), and that is true of all drives nowadays. See [this answer](https://unix.stackexchange.com/a/562895/86440). Your best bet is to try to write to the failing sectors, to see if they can be remapped, or try moving the bad files/directories as suggested in [user10489’s answer](https://unix.stackexchange.com/a/683972/86440). – Stephen Kitt Dec 26 '21 at 18:00