A handy command to create a dummy file of any size (Windows/Ubuntu)

table of contents
Hello,
this is Kawai from the Data
System Solutions Department.
Recently, I needed several tens of megabytes of test data while troubleshooting a data transfer issue.
There are times like this when you occasionally need a file of a specific size, right?
come in handydummy files. This time, I'll show you how to easily create these dummy files using commands in both Windows and Ubuntu environments.
Windows
■Execution environment
Windows 11 Pro
In Windowsfsutil`, you can quickly create files of any size using the `
For example, to create an empty file of 30MB, execute the following from the command prompt:
*If it doesn't create correctly, run the command prompt with administrator privileges.
fsutil file createnew testfile.txt 31457280
This commandbytesspecifies the file size in
30MB = 30 × 1024 × 1024 = 31,457,280 bytes
A file of exactly 30MB was created

Is the inside empty?
When you read a file created with the fsutil command, the file's contents are returned as all zeros (0x00). This means that the file does not contain any "non-zero" data.
More precisely, the data read appears as a repetition of "0x00" in hexadecimal, making it seem like a file filled only with zero data.
The important point is that this zero data is not actually read from a block on the disk.
While space is indeed allocated on the disk, it is unused space where data has not been physically written, so the system is designed to return zero data immediately without actually accessing the disk.
Ubuntu
In Linux environments,`fallocate`command behaves similarly.
For example, to create a 30MB file in an Ubuntu environment, you would execute the following:
■Execution environment
Ubuntu 24.04.2 LTS
$ fallocate -l 30M dummyfile.dat
▼If you check the contents, it will return the byte sequence “0x00” just like before
$ less dummyfile.dat "dummyfile.dat" may be a binary file. See it anyway? ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^ @^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^....
You can specify the size directly in MB or GB with the -l option, which is easier than Windows
That's how to create an empty file of a specified size for each OS!
complete
7
