[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: random bits in badblocks

On Mon, Dec 01, 2014 at 12:08:35AM +0000, Hendrik Boom wrote:
> The option -t random specifies that "the block should be filled with a 
> random bit pattern".
> Now, just how random is that bit pattern.
> Does it choose a random byte and fill the entire hard drive with it?

If I'm reading  the source correctly, Read-Write testing  happens in the
function  test_rw()[1] which,  in turn,  calls pattern_fill()[2]  at the
start of  a pass.  This pattern  is stored  in a  buffer (by  default 64
blocks) and used for the whole pass.

> Does it make up a random disk block and write that to the whole disk?
> Or does each block get its own randomly chosen data, presumably generated 
> by a pseudorandom generator so as to catch bad seeks?  In this case, is 
> the seed always the same, so I could take a disk I wrote on with -t 
> random and check it next week, the computer being off in between?

The random() call is seeded[3] by  the system time, so it's unlikely you
could get the PRNG to generate the same value. If you desire to do this,
it's better to supply your own test_pattern.

> -- hendrik
[1]: http://sources.debian.net/src/e2fsprogs/1.42.8-1/misc/badblocks.c/?hl=2#L584
[2]: http://sources.debian.net/src/e2fsprogs/1.42.8-1/misc/badblocks.c/?hl=2#L311
[3]: http://sources.debian.net/src/e2fsprogs/1.42.8-1/misc/badblocks.c/?hl=2#L1060

Attachment: signature.asc
Description: Digital signature

Reply to: