Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Hardware] HDD test with the command "badblocks"

Need help with peripherals or devices?
Post Reply
Message
Author
Ihamed
Posts: 34
Joined: 2021-01-31 09:23

[Hardware] HDD test with the command "badblocks"

#1 Post by Ihamed »

Hello,

I have bought a new HDD. I think it is in good health. (SMART is well.) But I decided to test it very good before I use it. So that I can send it back in the case it has some defects. It is empty. I have some ext4 partitions and a NTFS partition.

It is an internal 2 TB HDD.

So I made this:
k20221028-230925.jpg
k20221028-230925.jpg (22.9 KiB) Viewed 892 times

I just wonder:
It has said: "Testing with pattern 0xaa". At this time I thought: OK when it is finished with testing 0xaa, the test is finished.
... But...Now it is testing pattern 0x55 (What ever this is.)

So I ask me: How many patterns should be tested? Is this an endless test like RAM test?
I thought, it will test, if each point of the HDD can be written. But wasn't this now already tested with pattern 0xaa?

It is testing now about 11h .

Would appreciate an answer. Thank you.

dlu2021
Posts: 210
Joined: 2021-08-13 19:55
Location: Minnesota
Has thanked: 7 times
Been thanked: 41 times

Re: HDD test with the command "badblocks"

#2 Post by dlu2021 »

Looking at the man page, the -w flag that you passed means that will do a write test for following bit patterns, just to be thorough. It is verifying that none of the bits are stuck at either zero or one:

0xaa = 10101010
0x55 = 01010101
0xff = 11111111
0x00 = 00000000

User avatar
fabien
Forum Helper
Forum Helper
Posts: 682
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 61 times
Been thanked: 159 times

Re: HDD test with the command "badblocks"

#3 Post by fabien »

As man 8 badblocks says:
-w Use write-mode test. With this option, badblocks scans for bad blocks by writing some patterns (0xaa, 0x55, 0xff, 0x00) on every block of the device, reading every
block and comparing the contents.
A good habit is to always check the manual and assess the command you're about to launch instead of blindly pasting it.

Another way to check bad blocks is mke2fs -c option:
-c Check the device for bad blocks before creating the file system. If this option is specified twice, then a slower read-write test is used instead of a fast read-only test.
And yes, it's slow. But it's a good idea to do it because it can trigger early disk failure before actually using the disk and also because if there are bad blocks at least they are registered as such.

Ihamed
Posts: 34
Joined: 2021-01-31 09:23

Re: HDD test with the command "badblocks"

#4 Post by Ihamed »

Thank you both.

Why isn't it enough to test only (10101010 and 01010101) OR (11111111 and 00000000) ?
This way each point of the HDD would have been tested with 0 and 1.

(?)

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 68 times

Re: HDD test with the command "badblocks"

#5 Post by LE_746F6D617A7A69 »

Ihamed wrote: 2022-10-29 00:22 Why isn't it enough to test only (10101010 and 01010101) OR (11111111 and 00000000) ?
This way each point of the HDD would have been tested with 0 and 1.
Because HDD platters are not written with zeros or ones - those values are encoded as magnetic field gradients.
That 4 test patterns are needed to test every possible combination of the physical magnetic encoding.

But, in practice it's extremely unlikely that damaged block will fail only for one of the test patterns - it will fail for all of them, because each block is protected with CRC checksum.

Therefore, IMO it's better to use the extended SMART self-test (smartctl -t long), which is non-destructive, much faster, and can be performed on a working system.
Last edited by LE_746F6D617A7A69 on 2022-10-29 21:09, edited 1 time in total.
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: HDD test with the command "badblocks"

#6 Post by p.H »

LE_746F6D617A7A69 wrote: 2022-10-29 14:07 That 4 test patterns are needed to test every possible combination of the physical magnetic encoding.
Not quite. These patterns may have been useful with simple encoding schemes such as MFM or RLL used on floppy disks and old hard disks (pre-IDE/SCSI), but they are meaningless with modern ones. These patterns were chosen because they were supposed to have the fewest and the most transitions between low and high levels.

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 68 times

Re: HDD test with the command "badblocks"

#7 Post by LE_746F6D617A7A69 »

p.H wrote: 2022-10-29 15:03
LE_746F6D617A7A69 wrote: 2022-10-29 14:07 That 4 test patterns are needed to test every possible combination of the physical magnetic encoding.
Not quite. These patterns may have been useful with simple encoding schemes such as MFM or RLL used on floppy disks and old hard disks (pre-IDE/SCSI), but they are meaningless with modern ones. These patterns were chosen because they were supposed to have the fewest and the most transitions between low and high levels.
Not quite: those patterns are good for testing every encoding algorithm used today, because they are mutually exclusive ;)
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: HDD test with the command "badblocks"

#8 Post by p.H »

LE_746F6D617A7A69 wrote: 2022-10-29 21:02 those patterns are good for testing every encoding algorithm used today, because they are mutually exclusive
Just as any other arbitrary patterns, no more, no less. You cannot tell which ones will create the fewest or the most magnetic transitions.

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 68 times

Re: HDD test with the command "badblocks"

#9 Post by LE_746F6D617A7A69 »

p.H wrote: 2022-10-29 22:11 Just as any other arbitrary patterns, no more, no less. You cannot tell which ones will create the fewest or the most magnetic transitions.
Actually I can - those patters are forming a minimal set needed for testing all the possible combinations of bit state transitions - so they are universal ;)
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed

p.H
Global Moderator
Global Moderator
Posts: 3049
Joined: 2017-09-17 07:12
Has thanked: 5 times
Been thanked: 132 times

Re: HDD test with the command "badblocks"

#10 Post by p.H »

What matters is physical magnetic patterns actually written to the platters, not logical bit patterns written to the controller interface. How do you know which physical pattern is created by any logical pattern ?

Post Reply