dd
Commands can be easily implemented to create files of the specified size, such as
DD If=/dev/zero of=test bs=1m count=1000
Generates a 1000M test
file with full file content 0
( /dev/zero
/dev/zero
0 source for read from)
However, to actually write to the hard disk, the file production speed depends on the hard disk read and write speed, if you want to produce large files, slow
2.
In some scenario, we just want the file system to think that there is a huge file here, but it's not actually written to the hard disk
Then you can
DD If=/dev/zero of=test bs=1m count=0 seek=100000
The file created at this point is 100000MBin file system size, but does not actually occupy block, so the creation speed is equivalent to the memory speed.
Seek has the effect of skipping portions of the specified size in the output file, which achieves the purpose of creating large files, but not actually writing them.
Of course, because you don't actually write to the hard disk, you can create 100G of this type of file on a hard drive with a capacity of only 10G .
How to quickly create large files on a Linux system's hard disk