How to Create Extra Large Dummy Files Quickly With Linux

In Linux on 1~2 minutes
How to Create Extra Large Dummy Files Quickly With Linux

Create a 1GB dummy file using the dd command in your home directory.

dd if=/dev/random of=$HOME/dummy.data bs=1MB count=1024

The problem with the dd command is it takes a considerable amount of time to create the file. Especially, if you are creating a large file with dozens of gigabytes it will take a considerable amount of time to write the file. For that kind of situation, we can use the fallocate command. It will create a 10GB file within 1~2 seconds.

fallocate -l 10G dummy.data

Important! fallocate command does not work on ZFS and Ext3 file systems.

In addition to the above examples, there is another way to create a large file in Linux using the truncate command. This truncate command is quite strange, it will create a 50GB file within 1~2 seconds, but surprisingly it will not take such a disk space. So we tried to create a whopping 15TB (Terabyte) file and it worked.

truncate -s 15T dummy.data