Does the information about bad sectors provided by S.M.A.R.T. and badblocks survive formatting? [closed]

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?


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.