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.
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:
On linux based systems, we can use
dd for this task.
fallocate is included in the package
util-linux and is faster than
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
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.
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 using
fdisk -l | grep "Sector size"and block size can be determined using
blockdev --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 the
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.
Below some common sizes you can use for comparison when generating files:
|1.4MB (Floppy disk)||1474560|