2

I recently bought a new 1TB hard drive and I would like to do a couple of tests before I start using it (I prefer to know if there are problems or there may be problems now before it is too late).

The question is: How useful or how to scan it?

In Windows when a unit is formatted with zeros, if there is a defective sector, the unit automatically reassigns it for a new one (tests performed in this scenario). In Linux I'm not sure if this happens and I do not have to do these tests anymore. So, I can think of some options and at the same time some doubts:

  1. Format the unit with zero fill. If there are bad sectors, will they be replaced by new sectors automatically as in Windows?

  2. Execute the badblocks tool. This tool although I consider it very good, for a new disc I do not know if it is too exaggerated since it tests with 3 different patterns; demanding more time and wear, perhaps, unnecessary. Can only 1 pattern be programmed? Would it be advisable for this case?

  3. Run tool F3 - Fight Flash Fraud. This tool writes a file occupying the entire space of the unit and then checks it, so that the following tests (write / read / test) would be executed. It is used to detect fraudulent pendrives and because after writing the file it proves it, I suppose that this would detect any error in sectors of the surface. For what I think is a good alternative for testing.

These are the options that occur to me and I would like to be told, which of these options would be best applied in cases of new discs and also in cases of used discs and why.

muru
  • 197,895
  • 55
  • 485
  • 740
MarianoM
  • 655
  • Ubuntu uses e2fsck or older fsck if it's a extX filesystem type not sure how thorough the ntfsfix utility is on Ubuntu! – George Udosen Dec 20 '18 at 01:26
  • e2fsck Do you perform reading and writing tests? What is different about badblocks? – MarianoM Dec 20 '18 at 01:38
  • @George Udosen While the objective is the same (detect bad sectors) in this case I ask about the different options for checking sectors and which one to use depending on whether the disk is new (just to make sure it is in good condition) or is used. Which could guide the answers towards an explanation of the most recommended tool according to the case, the why and the different commands that can be used. – MarianoM Dec 20 '18 at 02:01
  • 2
    Please use the badblocks command this is a fresh HDD, was offering you options and where to look for information to that effect. It's safer with e2fsck when there's data but otherwise use badblocks! – George Udosen Dec 20 '18 at 02:04
  • 1
    @MarianoM Your question title is a duplicate of the candidate. Indeed the body of your question explores many different "what if scenarios". However rather than making your question unique I think it tends to make it too broad of a question which is another reason for closing. 6 of one or 1/2 dozen of another... – WinEunuuchs2Unix Dec 20 '18 at 04:32
  • @WinEunuuchs2Unix Ok, I'm so sorry. I'll have to be more specific when it comes to asking. Sometimes it bothers me a little because there are discussions that can contribute a lot, especially to learn the differences and different tools, but it consoles me to know that at least there is order in the community. – MarianoM Dec 20 '18 at 04:38
  • @MarianoM This website is structured to target a specific problem with a specific solution. In Ask Ubuntu a good Q&A is how do I spell cat? the answer is C-A-T. Forum topics do not fit well such as show me your favorite cat pictures or what does your cat do to catch a mouse? You might want to check out ubuntuforums.org for more free-form discussions. – WinEunuuchs2Unix Dec 20 '18 at 04:43

2 Answers2

3

No, OSes does not know it directly.

Bad block management is not done this way nowadays.

When hard drive detects CRC/ECC error on a sector/block, it will try to correct the data and remap the sector elsewhere, this is automatically done when you read the sectors.

This is called "spare sector" mechanism. Spare sectors are often from several hundred KBs to several MBs.

You can only find out the health status through "S.M.A.R.T.", and you should replace it before "reallocated blocks" are increasing too many(which indicates bad HDD health status).

If OS really encounters an I/O error on your drive and bad blocks marked by file system, it often means your spare sectors are depleted, you shouldn't use it anymore or you're going to lose (some) data.

For reading S.M.A.R.T., install Smartmontools by sudo apt install --no-install-recommends smartmontools and read smart status using command sudo smartctl -a /dev/sdX

Alvin Liang
  • 1,673
1

I have never used badblocks but from the the man badblocks pages:

DESCRIPTION
       badblocks is used to search for bad blocks on a device (usually a disk partition).  device is the special file cor_
       responding  to the device (e.g /dev/hdc1).  last_block is the last block to be checked; if it is not specified, the
       last block on the device is used as a default.  first_block is an optional parameter specifying the starting  block
       number for the test, which allows the testing to start in the middle of the disk.  If it is not specified the first
       block on the disk is used as a default.
       Important note: If the output of badblocks is going to be fed to the e2fsck or mke2fs  programs,  it  is  important
       that  the  block  size is properly specified, since the block numbers which are generated are very dependent on the
       block size in use by the filesystem.  For this reason, it is strongly recommended  that  users  not  run  badblocks
       directly, but rather use the -c option of the e2fsck and mke2fs programs.

It is adviced to use the command sudo e2fsck -c /dev/sdxX so block size issues won't come into play. Again from man pages

WARNING
       Never use the -w option on a device containing an existing file system.  This option erases data!  If you  want  to
       do  write-mode  testing  on an existing file system, use the -n option instead.  It is slower, but it will preserve
       your data.

       The -e option will cause badblocks to output a possibly incomplete list of bad blocks. Therefore it is  recommended
       to  use  it  only when one wants to know if there are any bad blocks at all on the device, and not when the list of
       bad blocks is wanted.
George Udosen
  • 36,677