Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In need of shell scripts / bash commands to verify data integrity of local harddrives, usb-drives, etc, ...

Like the famous; or something that is at least common within repositories. (h2testw writes a specific datastring over and over onto the medium, then reads it again to verify if it was written correctly and displays write/read time/speed.)

please no

 dd if=/dev/random of=/dev/sdx bs=1k && dd if=/dev/sdx of=/dev/null bs=1k

since it won't verify if everything was written correctly. It is only a test if read/write is successful to the device.

So far, I'm not too happy with

badblocks -w -v /dev/sdx1

either, since it seems rather slow and I don't know what it exactly writes, and if it considers wear-leveling on flash media.

There is also a program named F3 that needs to be compiled. Designed after h2testw, the concept sounds interesting, i'd just rather have it as a ready to go bash script.

share|improve this question
Please don't cross-post. Cross-posting is strongly discouraged -- if you post on one site and then change your mind it can always be migrated to another. – uther May 3 '12 at 13:44
@uther I'm sorry, i didn't know. I thought my chances to get an alternative answer would get better. If I'm not 100% happy with an answer, is it okay to not accept, even if it works? How do i improve my chances for another answer without setting up a bounty? – Mr. Bash May 3 '12 at 19:01

This is not bash, but badblocks is quite popular tool for testing hard drives under *nix, and pretty much as ubiquitous as dd.

From man-page:

-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. This option may not be combined with the -n option, as they are mutually exclusive.

You can also run non-destructive (-n) read-write test.

share|improve this answer
do i need to add a specific block size via -b option for flash media? keyword: wear leveling? and does bash only mean internal bash functions? thanks so far. – Mr. Bash May 3 '12 at 9:35
@Mr.Bash As far as I know, it is necessary to alter block size only f you are going to use badblocks output in mke3fs, otherwise there is no big difference. badblocks does not consider internal device way of mapping physical blocks to virtual ones (such as wear-leveling of flash drives), so no luck here. – aland May 6 '12 at 17:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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