4

I'm trying to test an embedded nand flash chip using the dd command (write random data to a file):

dd if=/dev/urandom of=/nand/storage/testnand/test.raw bs=100000 count=50 2> /dev/null

However, the unit I'm testing is running busybox v1, and it has been patched. The dd command is not recognized. Is there an alternative command that will help me achieve the same results?

suffa
  • 905

2 Answers2

4

You can try

  • cat /dev/urandom > /nand/storage/testnand/test.raw
  • for i in $(seq 1 10000000); do echo $i >> /nand/storage/testnand/test.raw; done

I can't think of much else that would work if you don't even have dd or cat...

allquixotic
  • 34,882
3
head -c $((100000*50)) /dev/urandom > test.raw

will save 100000 * 50 = 5000000 bytes, combining Bash's Arithmetic expressions and head's -c number_of_bytes parameter.

For debugging: expanding on allquixotic's idea, this command prints "$i done" at 1000, 2000, etc.

{ for i in {1..100000}; do echo $i; if (( ($i % 1000) == 0 )); then echo "$i done" 1>&2; fi; done } > test.raw
ignis
  • 272