Use DD to Create File of any Size

Tagged with: , , , , ,

Use the DD command to create a 10 MB (10*1024*1024=10485760 bytes) size file named testfile_10MB


dd if=/dev/zero of=testfile_10MB bs=10485760 count=1

Original Article

4 Responses to “Use DD to Create File of any Size

  • 1
    Carb0n
    January 29th, 2009 10:27

    I’d suggest you put the ‘bs=’ equal to that of your disk block size. That’ll help easier syncing… I don’t know why, but I suggest that is the best option.

    dd if=/dev/zero of=test-dumb-file bs=1K count=100

    and adjust via the ‘count=’ option

    YMMV, I guess

  • 2
    Ravi
    February 26th, 2011 23:35

    I agree with Carb0n..
    my reason is the bs size limit that i encountered making a 4GB file

    dd if=/dev/zero bs=4G count=1
    yields a 2GB file.. that too silently ! Imagine using it in a script and getting a wrong size !

    dd if=/dev/zero bs=1K count=4M
    yields a 4GB file.. just like I wanted

  • 3
    Ravi
    February 26th, 2011 23:36

    oops.. above commands need a of=foo .. sorry missed that

  • 4
    toto
    March 20th, 2011 05:24

    If you are limited to 4GB this may be because you have some 32bit limitation somewhere (OS architecture,or dd version compiled for 32bit only)

    If the source code deal with signed integer, then the range will be from -2Gb to +2Gb which is a range of 4Gb (32bit) but in this case you may encounter limitation to 2Gb when creating your file.

    2^32=4294967296

Leave a Reply