1

I wanted to run an fsck check on my 5TB external hard drive on my raspberry pi after I noticed that cp fails on a couple of files.

This is the output:

 $ sudo e2fsck -c -v /dev/sda
 e2fsck 1.44.5 (15-Dec-2018)
 Checking for bad blocks (read-only test):   0.46% done, 5:04 elapsed. (0/0/0 errors)

There has been zero progress for hours now. The elapsed time is stuck as well. This is actually my second attempt. Before I tried sudo e2fsck -p -c -v /dev/sda. This one doesn't give any output, that's why I let it run for a whole week before terminating.

My drive is unmounted, partitionless, and freshly formatted with mkfs.ext4. Output from ps:

 $ ps -a
PID TTY          TIME CMD
1075 tty1     00:00:00 bash
8404 pts/1    00:00:00 sudo
8405 pts/1    00:00:04 e2fsck
8446 pts/1    00:00:00 sh
8447 pts/1    00:00:05 badblocks
23605 pts/2    00:00:00 ps

I noticed on my first attempt, that it was impossible to send a SIGINT, SIGTERM, or SIGKILL to badblocks.

3
  • 1
    Check the SMART data of the disk. It might have bad sectors.
    – harrymc
    Oct 30, 2021 at 19:19
  • Okay. I ran a selftest with smartctl. ` smartctl --test=short /dev/sda -d sat` It seems there is at least one bad sector. Status: Completed: read failure. LBA_of_first_error: 47969664. Is there any way to check if these bad sectors can be recovered or if they are caused by hardware faults?
    – Deffa
    Oct 30, 2021 at 20:15
  • Id also be meeping my eyes on the system logfile to see if the drive is throwing up many errors.
    – davidgo
    Oct 31, 2021 at 1:47

1 Answer 1

0

The firmware of the disk will try to recover any read error, itself, and if successful will map the sector to a spare one, so no error will be reported to the OS.

The firmware will only report an error if it doesn't manage to recover the contents of the sector.

So if you have a bad sector, it's beyond salvage, except perhaps by specialists with special equipment.

Your disk might be failing, so a new disk might be required. To copy a disk while omitting errors, use ddrescue. The new disk will not have a bad sector that will block e2fsck, so the file-system can be repaired (expect some data-loss).

3
  • To my knowledge, there are two types of bad blocks. Soft and Hard. I don't know if the firmware remaps both types, but I guess so and I would like to repair soft bad sectors. The reason I think these might be soft faults is because cp failed ONLY on files that were in use during regular operation and I know the device lost power a couple of times and that this can cause soft errors. I might be totally wrong though. Thanks nevertheless.
    – Deffa
    Oct 30, 2021 at 20:43
  • If you suspect errors that can be repaired, save your data and perform a low-level format of the disk. ddrescue can be set to try many times.
    – harrymc
    Oct 31, 2021 at 8:54
  • I did now perform a low-level format. After that the smartctl tests completed without any errors. I also ran fsck again, this time it completed without getting stuck and without finding any error. I don't know why fsck couldn't handle these bad sectors, but I guess I misunderstood what fsck actually does.
    – Deffa
    Nov 2, 2021 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.