1

Gentlemen,

I need some fatherly advice about e2fsck: I have a disk that has been getting cranky, and "e2fsck -ccv" was indeed showing bad blocks. However, I repartitioned the disk, and now the same command reports that the disk is in perfect health! What happened to my bad blocks? Of course the partitions are now all empty, but surely a bad block is still a bad block? Has the disk's internal housekeeping somehow flagged those blocks off to the point that even e2fsck doesn't get a look at them? Or does e2fsck not work on empty partitions? Or has a repair somehow been made? How can I find out?

And: what are the practicalities of using '-c' vs. '-cc', that is, when and where do I want a read-write test vs. a read-only test?

And: after repartitioning, I tried this: "mkfs.ext4 -vcc ..." in the hopes of checking the disk at the same time as creating the FS, but it took hours and hours. In constrast: "e2fsck -ccvy ..." after the FS was created was much faster, less than an hour for a 500GB disk with 12 partitions. Why? One needs to know the facts of life before one starts fscking.

  • 1
    Buy a new disk if you value your data. – Rui F Ribeiro Dec 9 '16 at 16:42
  • Yeah, I'm only using the disk for archive backup and it's highly redundant -- don't want to take chances, still the issues I raise are of interest on principal. – Ray Andrews Dec 9 '16 at 17:18
0

Filesystem badblock lists are obsolete (ignoring flash filesystems, because you're talking about ext4). bad blocks are remapped by the drive. Look for errors - there should be a permanent log of these in SMART counters. If you see one or more errors / "bad blocks" / "bad sectors" you should consider the disk untrustworthy.

If your valued data is saved redundantly (RAID, backups), some people develop methods to re-establish trust in the drive over a testing period.[*] You aren't using RAID to start with, so I'm not able to recommend this.

Those are the facts of life. The behaviour of mkfs v.s. fsck is unfortunate. A read-write test is still potentially useful to stress-test a newly-acquired drive. It should take more than one hour, because disk IO speed is around 100MB/s and you want to both write and read the whole disk. (The relative performance of modern disks also affects the viability of certain RAID modes). I also notice that badblocks -w runs several passes with different patterns, which would explain why it takes so long. Since badblock lists are obsolete, you can run badblocks directly and just look for any error.

However given how long this would take & that you could not use the disk for this period, you might prefer to use the longest available SMART test, or simply dd if=/dev/sdX bs=10M of=/dev/null and see if you get any read errors.

SMART features are available in GNOME Disks. (It also has a benchmark feature). The error counters are measured in sectors; you can just look at all the counters that say "sectors" and check that they're all zero. It sounds like you might have some under "reallocated sectors".


[*] Writing new data to a bad sector will clear the error. This works by writing the logical sector to a different physical sector in a "spare area", and the drive will make sure to remap future reads of the logical sector.

  • Thanks, how do I access this SMART stuff? The disk is SATA so I'd expect it to be up to data as far as SMART is concerned. That 'dd' idea sounds very cool. – Ray Andrews Dec 9 '16 at 17:16
  • 0 /aWorking/Zsh 2$ dd if=/dev/sdc bs=10M of=/dev/null dd: error reading ‘/dev/sdc’: Input/output error 14+1 records in 14+1 records out 152440832 bytes (152 MB) copied, 8.0381 s, 19.0 MB/s – Ray Andrews Dec 9 '16 at 17:23
  • How do you format in comments? Does the above bulldoze past any SMART safeties? That is, will SMART protect me from the 'dd' errors? And why didn't 'badblocks' find anything? – Ray Andrews Dec 9 '16 at 17:31
  • 1
    GNOME Disks, or look up smartctl. unix.stackexchange.com/help/formatting . dd does not bypass SMART - it accesses the disk using the same interface badblocks does, and it's the same way the filesystem does (w.r.t SMART anyway). I would definitely stop trusting the disk if I saw that error from dd. My dd command should give the same results as a badblocks read test. As I say, you can run badblocks manually, and the manpage says you can get a progress indicator. – sourcejedi Dec 9 '16 at 18:14
  • Sorry, specifically in comments you can use inline formatting : `code` but not paragraph-level formatting, because you're only allowed one paragraph :). Or scroll down to "comment formatting" in the link. – sourcejedi Dec 9 '16 at 18:32

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.