方法:

dd if=/dev/zero of=test.txt bs=1M count=1000

[root@logstash tmp]# dd if=/dev/zero of=test.txt bs=1M count=1000
1000+0 records in
1000+0 records out
1048576000 bytes (1.0 GB) copied, 0.626446 s, 1.7 GB/s
[root@logstash tmp]# ls -l test.txt 
-rw-r--r-- 1 root root 1048576000 Jul  4 09:06 test.txt
[root@logstash tmp]#
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

生成一个文件名为test.txt,大小为1G的文件