I wanted to create a 300GB file with random data so I used this command in terminal

dd if=/dev/urandom of=random.txt bs=300g count=1

But what I receive is

dd: /dev/urandom: Invalid argument
0+0 records in
0+0 records out
0 bytes transferred in 0.000042 secs (0 bytes/sec)

I originally thought that is due to not writing bs=300G but capitalizing gives me dd: bs: illegal numeric value.

Thanks for the help in advance.

  • 2
    Does it work if you try smaller block size? For example dd if=/dev/urandom of=random.txt bs=1g count=300? I tried bs=1g count=2 and it works for me to make a 2GB file - I don't have disk space for a 300GB. btw it seems to take almost 1 minute per GB.
    – lx07
    Nov 23, 2019 at 9:25
  • the bs data is the block size. It must fit in memory/swap space. Nov 23, 2019 at 19:50

1 Answer 1


You can't read 300 gigabytes at once (in one block). Try

dd if=/dev/urandom of=random.bin bs=2g count=150


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .