1

I have read many questions and answers on SuperUser, ServerFault, and other websites about this topic, but I am still a little bit confused about S.M.A.R.T. and badblocks.

I saw that S.M.A.R.T. stores the information about bad sectors at a memory location that is only accessible by the firmware of the disk, not by the OS. When mke2fs uses the output of badblocks, where does it store the location of the bad sectors? Does it tell S.M.A.R.T. about those sectors?

I guess the practical questions I have are the following ones:

  1. If I format a partition with mkfs.ext4 -cc and bad sectors are found, are those sectors still known if I reformat the same partition with only mkfs.ext4 (without -c or -cc) after?

  2. If the answer to the first question is no, what would be the best way of making a drive aware of its bad sectors so that the next owner of the drive doesn't run into problems related to bad sectors if it is reformatted?

  3. In practice, if I was given hard drives that were used in office desktops for about 8 to 10 years, should I be worried that there might be bad sectors on them and run diagnostic tests? Or should I not waste hours with this because it's so unlikely that it's not worth it?

4
  • 2
    One, single question per post please. This is a good question. Just ask one please. Oct 9, 2021 at 3:14
  • Agreed with @music2myear: Just lose the last 3 specific questions and maybe summarize those concerns in one very simple paragraph and this is a solid question. Oct 9, 2021 at 3:30
  • One important note: reallocated sector count tends to increase exponentially to time, so once you have more than a few bad sectors, the safest bet is to backup and replace the disk. an increase doesn't always indicate imminent death, but increases in Reallocated Sector Count, and Raw Read Error Rate most commonly presage the failure of a disk. Oct 9, 2021 at 8:53
  • My question is all over the place, sorry about that. If I split it into three questions, am I allowed to quote the relevant parts of dirkt's answer?
    – optical
    Oct 14, 2021 at 1:18

1 Answer 1

1

I saw that S.M.A.R.T. stores the information about bad sectors at a memory location that is only accessible by the firmware of the disk, not by the OS.

Yes. Also keep in mind that the harddisk firmware can reallocate sectors - so it can "replace" a bad sector at a logical address that the OS uses with a good sector at the same logical address, but a different physical address, without the OS noticing. (The number of times this has been done can be seen among the SMART values).

When mke2fs uses the output of badblocks, where does it store the location of the bad sectors?

In a special table in the filesystem.

Does it tell S.M.A.R.T. about those sectors?

No. In particular, the badblocks sector are addresses are logical addresses, so when the harddisk firmware reallocates a sector, and it becomes a good sector, it's still marked as bad in the filesystem table.

Or in other words, with the advent of SMART and reallocating bad sectors in the harddisk firmware, storing bad blocks in the file system has become useless, and you shouldn't do it.

If I format a partition with mkfs.ext4 -cc and bad sectors are found, are those sectors still known if I reformat the same partition with only mkfs.ext4 (without -c or -cc) after?

No.

what would be the best way of making a drive aware of its bad sectors so that the next owner of the drive doesn't run into problems related to bad sectors if it is reformatted?

The best way is to do nothing about bad sectors and let the harddisk firmware handle it. You can force reallocation of a bad sector by writing to it.

If the harddisk runs out of space to reallocate sectors, this harddisk is usually damaged so much that you should stop using it.

In practice, if I was given hard drives that were used in office desktops for about 8 to 10 years, should I be worried that there might be bad sectors on them and run diagnostic tests?

You should look at the SMART values, they tell you what shape the disk is in. High read error counts, high seek error counts, and lots of reallocated sectors say that this disk is going to die soon.

Running a disk scan (both via badblocks and via the SMART internal tests) doesn't hurt, but the first place to look is the SMART values.

2
  • I think this varies by filesystem and OS type. for NTFS on Windows, when a bad block is encountered, SMART increments the Current Pending Sectors Count, and then when you subsequently run chkdsk in thorough mode, the Current Pending Sector Count is decremented, and the Reallocated Sector count is incremented as the block is reallocated. Oct 9, 2021 at 8:22
  • @FrankThomas this is specifically about "mkfs.ext4". So while it does vary by filesystem and OS type, this wasn't the question, which is about the filesystem "ext4" and the OS "linux". Pending Sector Count vs. Reallocated Sector count corresponds to "bad blocks detected during read" and "blocks reallocated because of a write or lots of reads", the fact that chkdsk in thorough mode provokes this is incidental. Windows doesn't "communicate" with SMART, either. It can't, because there aren't any SCSI commands for that (read the standard if you don't believe me).
    – dirkt
    Oct 9, 2021 at 10:39

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