4

I have an external drive that is most certainly failing (4+ years). I keep getting I/O errors when reading/writing, but before I replace it I do want to try to extend the life a little more.

I understand that I can use fsck -c /dev/sdX to mark bad blocks, but does this also reindex the filesystem around those blocks as well? In my searches I haven't got a solid answer.

When I try fsck -c on the unmounted drive I get a bad superblock message, so I was thinking of reformatting, but this also hasn't helped in the past in terms of the I/O error, I've done it a few times before.

EDIT: For clarification, this is an old Verbatim external drive, SATA drive in an enclosure that has a SATA-to-USB with a power adapter. At this point it is just a toy drive (I've got everything else backed up onto a NAS) hooked up to a Raspberry Pi for futzing around.

As far as the question my main though was this: If I have a corrupt block that's making reading and writing data fail (according to dmesg and badblocks, is it possible to mark that block "dead" and use the next good block to read/write to?

  • 2
    If you stretch the lifetime of a failing device, you will be negatively surprised at the worst possible moment. Are you sure this is what you want? Storage is cheap. Time and anguish are not. – waltinator Sep 20 '17 at 14:13
  • He may need to retrieve important data from it. Don't just say this is time-wasting. – Cynplytholowazy Sep 20 '17 at 14:15
  • It's unclear what you mean by "reindex the filesystem around those blocks". Also, I/O errors may or may not be related to bad block. In your case, it looks like they are not. – mikewhatever Sep 20 '17 at 14:19
  • Possibly related: https://askubuntu.com/questions/291570/mark-bad-sectors-on-hard-drive-without-formating – Terrance Sep 20 '17 at 14:20
  • is this a desktop? read errors can be cause by speed variances from bad bearings. remounting the drive to stand on it's side instead of flat can increase life as the disks will ride on different bearings. – ravery Sep 20 '17 at 14:23

1 Answers1

5

Bad blocks are remapped when trying to perform disk writes (only). When a bad block is remapped, data from that block is placed into another spare good block. Depending on the number of bad blocks, file corruption can still occur.

The proper way to bad block your disk is:

Note: do NOT abort a bad block scan!

Note: do NOT bad block a SSD

Note: backup your important files FIRST!

Note: this will take many hours

Note: you may have a pending HDD failure

Boot to a Ubuntu Live DVD/USB in “Try Ubuntu” mode.

In terminal...

sudo fdisk -l # identify all "Linux Filesystem" partitions

sudo e2fsck -fcky /dev/sdXX # read-only test

or

sudo e2fsck -fccky /dev/sdXX # non-destructive read/write test (recommended)

The -k is important, because it saves the previous bad block table, and adds any new bad blocks to that table. Without -k, you loose all of the prior bad block information.

The -fccky parameter...

   -f    Force checking even if the file system seems clean.

-c This option causes e2fsck to use badblocks(8) program to do a read-only scan of the device in order to find any bad blocks. If any bad blocks are found, they are added to the bad block inode to prevent them from being allocated to a file or direc‐ tory. If this option is specified twice, then the bad block scan will be done using a non-destructive read-write test.

-k When combined with the -c option, any existing bad blocks in the bad blocks list are preserved, and any new bad blocks found by running badblocks(8) will be added to the existing bad blocks list.

-y Assume an answer of `yes' to all questions; allows e2fsck to be used non-interactively. This option may not be specified at the same time as the -n or -p options.

heynnema
  • 70,711