Ever wanted to create dummy files to test if your configured quota works as expected or to have a reason to buy a new disk?
Here is your way to go.
Windows
You can create a dummy file using fsutil
where the created file is filled with zeros. If you have compression in place, this file will not consume a big amount of space.
To create the file, you can use the following command within cmd or PowerShell:
|
|
Linux
On linux based systems, we can use fallocate
or dd
for this task. fallocate
is included in the package util-linux
and is faster than dd
.dd
, which is also known as disk dump or disk destroyer, is slower and comes with more risk but also with more options. The package should be preinstalled on your system already and comes mostly with the coreutils
package.
Files created with fallocate
is similar to fsutil
of Windows which creates a file filled with zero. This file will compress pretty well but may not consume any disk space if the underlaying file system has compression enabled.
|
|
With dd
we do have more possibilities when creating a new file. To create a file filled with zero, we can simply use the following command:
|
|
The following parameters were used in the command above:
- if - Input File: File from which to read from
- of - Output File: File to which you want to write
- bs - Block Size: Size of blocks you want to write. Ideally the same size as the block size of the underlaying disk.
Disk sector size can be determined usingfdisk -l | grep "Sector size"
and block size can be determined usingblockdev --getbsz /dev/<disk>
For SSD and HDD it’s mostly 512 bytes or 4096 bytes. - count: Number of blocks. If your block size is 4096 and count is 1024, the created file will have a size of 4 MB.
Additionally, you have more possibilities to then to use if=/dev/zero
as source for generating files.
For example you can use:
/dev/urandom
: Will be very slow depending on the available entropy, CPU speed and disk write speed. This file will hardly compress efficiently./dev/<disk>
: Will use an attached disk as source. This way you can clone an entire disk to a file. In this case you can omit thebs
andcount
parameters.
Please note that if you want to make a backup and mix up if and of, dd
will not hesitate to override all your data as fast as it can at the moment you execute the command.
Common sizes
Below some common sizes you can use for comparison when generating files:
Size | Length |
---|---|
10KB | 10240 |
1MB | 1048576 |
1.4MB (Floppy disk) | 1474560 |
25MB | 26214400 |
682MB (CD) | 715128832 |
1GB | 1073741824 |