/dev/zero can output 0's (null characters) endlessly. I am looking for a technique to output 1's (0xFF or 0b11111111) endlessly in a similar manner as /dev/zero.
The following dd statement writes 4 terabytes of 0's to the drive /dev/sdb. This dd statement does not cause any memory shortage.
dd bs=4K count=1G if=/dev/zero of=/dev/sdb
On the other hand, I would like to write 1's almost endlessly. The following perl statement attempts to write 4 terabytes of 1's. However, its huge buffer at the redirection causes the "Out of memory" error, and hence the perl statement fails.
Is there any technique to output 1's (0xFF or 0b11111111) endlessly in a similar manner as /dev/zero? I wonder if this goal can be achieved by using /dev/loop or something.
Thanks a lot in advance.
----------
Mac OS X note: The dd command on Mac OS X has slightly different syntax from that on Linux. The dd command on Mac OS X may expect lowercase letters for k, m and g. If the above dd statement does not work on Mac OS X, try the following.
Thanks, pludi. However, is there any faster technique?
The technique "perl -e 'print chr(0xFF) while(1);'" is too slow compared to /dev/zero.
The "perl ... while" method is 400 times slower than /dev/zero, if there is almost no bottleneck by the output destination.
Even in a real world environment where the flow is bottlenecked by the slow hard drive, the "perl ... while" method is 2.5 times slower than /dev/zero.
Can anyone think of a technique to output 1's (0xFF or 0b11111111) endlessly nearly as fast as /dev/zero? Is it possible to custom-make a pseudo-device similar to /dev/zero?
One of the reasons perl is "slow" is because it is an interpreted language, not a compiled language. There are lots of disk scrubber apps out there....