How to use dd to fill drive with 1’s

dd

Filling a drive with /dev/urandom seems to be very slow, so I created a file filled with FF:

dd if=/dev/zero ibs=1k count=1000 | tr "\000" "\377" >ff.bin

I'd like to fill the drive with copies of this file but the following command only writes once:

dd if=ff.bin of=/dev/sdb count=10000

How do I fill the drive with copies of the file, or is there a faster way to fill the drive with 1's?

Best Answer

Simply do:

tr '\0' '\377' < /dev/zero > /dev/sdb

It will abort with an error when the drive is full.

Using dd does not make sense here. You use dd to make sure reads and writes are made of a specific size. There's no reason to do it here. tr will do reads/writes of 4 or 8 kiB which should be good enough.