I’ll often create a file of a particular size with a trick like
dd if=/dev/zero of=1gb.dd bs=1M count=1024
or perhaps even
dd if=/dev/urandom of=1gb.dd bs=1M count=1024
dd if=/dev/random of=1gb.dd bs=1M count=1024
But what if I want to get all 1’s instead of 0’s or random?
For random data, in almost all cases use
/dev/urandom. (You can also use/dev/random, but that’s much much slower because it’s entropy-bound.urandomis a PRNG which self-seeds fromrandom.)For a non-zero file, I’d suggest something like this:
Obviously, customise the 0xff and 1000 to taste.