0

I would like to run badblocks on one entire hard drive (8TB). For example:

$ sudo badblocks -wsv /dev/sdb

But, this will take days to complete. For some reasons, I can not leave the test PC on for days. I have to shut it down everyday.

Is that a good idea to create some temp partitions, for example format the drive to 8 fat32 partitions and then run badblocks on each partition instead:

$ sudo badblocks -wsv /dev/sdb1
$ sudo badblocks -wsv /dev/sdb2
$ sudo badblocks -wsv /dev/sdb3
$ sudo badblocks -wsv /dev/sdb4
$ sudo badblocks -wsv /dev/sdb5
$ sudo badblocks -wsv /dev/sdb6
$ sudo badblocks -wsv /dev/sdb7
$ sudo badblocks -wsv /dev/sdb8

In such case, I can power off the test PC after each badblocks on each partition.

After all tests are completed, I will reformat the drive to one single partiton with proper filesystem on it later.

Is this a good idea?

Thanks a lot.

sgon00
  • 605
  • 2
  • 10
  • 20
  • And what you intend to do if some of tests give out actual bad blocks? – Nikita Kipriyanov Jun 25 '21 at 06:02
  • @NikitaKipriyanov this is a new hard drive I bought online. If some of tests give out actual bad blocks, I will simply return the drive to the seller. Cheers. – sgon00 Jun 25 '21 at 06:04
  • Then I'd just read a SMART, write a whole drive from /dev/zero, read a whole drive into /dev/null and check SMART again. Also run some built-in tests. Of course, reads could be done in parts, and you don't need partitions for that. – Nikita Kipriyanov Jun 25 '21 at 06:12
  • @NikitaKipriyanov I don't trust SMART test. SMART test is ran by manufacturer software. But some manufacturers testing programs do not print full test results and allow a certain number of bad sectors. SMART tool may print completed without error even if it has some bad sectors. SMART tests do NOT do any write test too. – sgon00 Jun 25 '21 at 06:20
  • Do you understand *everything* you are you doing with hard drive is ran by the manufacturer software? Any your test will depend on it somehow. Also, SMART *is* the definitive information source about the internal state of the drive. It is very strange to avoid id, especially when you need to capture as many information as possbile. It isn't perfect, but that's better than nothing. – Nikita Kipriyanov Jun 25 '21 at 06:28
  • 1
    @NikitaKipriyanov There is no contradiction between what you said and what I said. I have no ideas why you said the above words. I never say I will avoid SMART test. I never say SMART is not better than nothing. Running SMART and running badblocks can both be done. I just don't think SMART test is enough for testing my new drive. I will run badblocks once and run SMART tests too and repeat smart tests later. I don't know why you're trying to stop me running badblocks. It's OK you think SMART test is good enough. But I think SMART test alone is not enough and I would like to run badblocks too. – sgon00 Jun 25 '21 at 06:50

3 Answers3

1

for example format the drive to 8 fat32 partitions and then run badblocks on each partition

Partitions and filesystems are different concepts (compare this answer). You don't need filesystems at all. In fact you don't even need partitions either. See man 8 badblocks, you can specify last-block and first-block after device:

badblocks [ -svwnf ] [ -b block-size ] [ -c blocks_at_once ] [ -e max_bad_blocks ] [ -d read_delay_factor ] [ -i input_file ] [ -o output_file ] [ -p num_passes ] [ -t test_pattern ] device [ last-block ] [ first-block ]
Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
  • Yeah, you are right and I actually already knew the information you provided before asking this question. But I don't know how to properly caculate and specify last-block and first-block. I am afraid if I will make any mistakes. There are some people online talking about if the block size is not calculated correctly, it will show some false results. So to make my life easier, I think formating to multiple partitons might be easier solution for me so that I don't need to calculate the block numbers manually. Can I specify any block number regardless what block number I use etc...? – sgon00 Jun 25 '21 at 06:16
  • @sgon00 Partitioning is also about first and last blocks (well, sectors). On the other hand there are programs that can calculate this for you. So yes, your idea with partitions makes sense. Note you need a partition table outside any partition, so to test the whole disk you will still need to test some unpartitioned space. – Kamil Maciorowski Jun 25 '21 at 06:24
  • Yeah, I plan to use `gparted` to create partitions, since I am lazy to caculate the correct block numbers. And I do realize there are some unpartitioned space. I will use `fdisk -l` to check them. and specify those unpartitioned block numbers manually in the end. I am not sure if this is a good idea (plan) or not. BTW, If I use `-b 4096`, is that safe that the `last-block` and `first-block` numbers are multiples of 4096 if I don't use partition approach? I just don't know how to calculate the correct block number. Thanks a lot. – sgon00 Jun 25 '21 at 07:00
  • @sgon00 It seems it would be good if you knew how to calculate anyway. After all these comments I think there's significant "[XY problem](https://meta.stackexchange.com/a/66378/355310) factor" in your question. – Kamil Maciorowski Jun 25 '21 at 07:06
  • @sgon00 `last-block` and `first-block` are ordinal numbers. The block number `N` begins after `N*blocksize` bytes and takes `blocksize` bytes. The very "first" block has number `0` and begins after `0` bytes. Optimally the block size (`-b`) should be the *physical* sector size of the device. – Kamil Maciorowski Jun 25 '21 at 07:16
  • Thanks a lot for your last comment. Refer to this [question](https://superuser.com/questions/1506199/), `badblocks` always report bad block for the last block somehow. I am new to badblocks command. I don't know the story and logic behind. That's why I was afraid to specify first-block and last-block manually. – sgon00 Jun 25 '21 at 11:52
0

Your idea is bad. Using badblocks is a bad idea as well when you are running your disk under time constraints.

Use smartmontools to dump all SMART information into one file:

smartctl /dev/sdX > mysmart.txt

Replace the X in sdX by the drive label in question.

Then run ddrescue with your drive being the source and the null device as target using a log file. If a sector cannot be read, the log file gets an entry. You can interrupt and continue this task at will when you are always using the same log file. Furthermore you get defect information on sector level which is more precise than on aggregated level like block level, where a block typically consists of a couple of sectors. To run ddrescue in stop-and-go mode you don't need to create additional partitions.

At then end refetch the smart parameters because running ddrescue on the whole disc will update your smart parameter list in case of failures.

r2d3
  • 3,298
  • 1
  • 8
  • 24
-1

Frame challenge

I think you're completely wasting your time.
Just use the drive.
If it turns out to be a lemon, send it back.

The very same tools you run to sequentially test for bad blocks & the ones you use to access the SMART data both rely on the drive's own firmware to actually do the mapping & reporting - so you can't really trust one yet not the other… they're the same thing.
The drive is perfectly capable of mapping out bad blocks every time it finds one. That's its job. All you do by making it do them all in one go is waste your time & perform an unnecessary write/read cycle of every block. The manufacturer already did that before shipping.

Tetsujin
  • 47,296
  • 8
  • 108
  • 135
  • You actually answered the question I asked in apple stackexchange too. I did google online and many people have different opnions. Some suggest running `badblocks` on a new hard drive. Some also suggest to run smart tests after running `badblocks` and check values of reallocated & current pending sector count. I agree with them. I also need to determine whether the drive is good or bad within 7 days. I can only return it back to seller within 7 days. If it turns out to be a lemon after 7 days, I will NOT be able to send it back. That's the policy in my place. – sgon00 Jun 25 '21 at 10:54
  • Where is 'your place' & how does that define policy? The EU gives you 30 days to simply 'change your mind' without having to prove a fault, and 6 months if a fault develops [inside 6 months a fault is deemed to have been there from the start, ie, a lemon]. – Tetsujin Jun 25 '21 at 10:57
  • I am not a native English speaker. If "policy" is not the right word, I am sorry about it. In my country, I can only return my online product within 7 days. I can only ask the seller to fix a faulty product or maybe exchange within 15 days free of charge. After 15 days, I am out of luck. I am sure that the time varies on different countries. – sgon00 Jun 25 '21 at 11:04
  • I guess if your consumer protection laws are so bad you have to actually do all this extra work to prove any potential RMA claim, while the seller sits back & laughs, there's not a lot you can do. – Tetsujin Jun 25 '21 at 17:06