Create a File of Given Size
July 31st, 2008Sometimes it’s useful to be able to create a file of a specific size for testing purposes, for example to test network bandwidth by copying a large file of known size. It easy to do on both Linux and Windows.
First on Linux:
dd if=/dev/zero of=file.img bs=1k count=10000
This creates a 10MB file called file.img, bs is the block size so this command would have the same effect.
dd if=/dev/zero of=file.img bs=1M count=10
You can try different block sizes and counts to get the desired result.
Now on Windows:
fsutil file createnew file.img 10485760
This creates a file called file.img of 10485760 bytes (1024*1024*10).