Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 3 down vote accepted
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
share|improve this answer
    
Ooh nice! :) Didn't think of generating data with head... –  allquixotic May 3 '13 at 18:19
    
@ignis - If I wanted this script to continue until there is an error or the user stops, would I need to add /dev/null back? –  suffa May 3 '13 at 18:30
    
@suffa The user can stop with Ctrl+C, and I believe the command will stop automatically if there's an error. 2>/dev/null merely hides the error messages, in no way it will influence the command itself. –  ignis May 3 '13 at 18:34
    
@ignis - keep getting a syntax error on the debugging section you added recently. –  suffa May 3 '13 at 19:18
    
@suffa I do not get errors, on Bash 4.2.37(1) / Ubuntu 12.10, Bash 4.2.45(2) / Arch Linux 2013.04, Bash 4.2.39(1) / Fedora 18. Does echo $0 return "bash"? If so, what version does bash --version print? –  ignis May 3 '13 at 19:39

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...

share|improve this answer
    
Expanding on your idea, I'd do { for i in {1..100000}; do echo $i; done } > test.raw which opens test.raw only 1 time –  ignis May 3 '13 at 18:29
    
@ignis does the ellipsis in your comment account for: {1 seq 10000000}? –  suffa May 3 '13 at 18:34
    
@suffa Nope, it's an alternative syntax for seq 1 100000, documented here and here –  ignis May 3 '13 at 18:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.