A little convenient. Dummy file creation command (Windows/Ubuntu) that can specify any size
table of contents [非表示]
Hello
the Sky Data
System Solutions Department
The other day, when I was troubleshooting a data transfer, I needed several tens of MB of test data.
There are occasional times like this where you might want a file of a specific size.
Dummy files are useful in such cases . This time, we will show you how to easily create this dummy file from commands in Windows and Ubuntu environments.
Windows edition
■Execution environment
1 | Windows 11 Pro |
On Windows , you can quickly create files of any size you like by using the command
fsutil For example, if you want to create an empty 30MB file, run it from the command prompt as follows:
*If it is not created properly, run the command prompt with administrator privileges.
1 | fsutil file createnew testfile.txt 31457280 |
specifies
the file size bytes 30MB = 30 × 1024 × 1024 = 31,457,280 bytes
A perfect 30MB file has been created
Is the contents "empty"?
When a file created with the fsutil command is read, all the contents of the file are returned as zero (0x00) data. This means that the file does not contain "non-zero" data.
To be precise, when viewed in hexadecimal, it looks like a file filled with zero data, as it is a repeat of "0x00".
The key is that this zero data is not actually read from blocks on disk.
There is certainly space available on the disk, but the data is unused space that has not been physically written to it, so in reality, zero data is returned immediately without accessing the disk.
Ubuntu Edition
In a Linux environment, the fallocate command behaves similarly.
To create a 30MB file in an Ubuntu environment, run the following:
■Execution environment
1 | Ubuntu 24.04.2 LTS |
1 | $ fallocate -l 30M dummyfile.dat |
▼When checking the contents, it returns a byte sequence of "0x00" as before.
1 | $ less dummyfile.dat "dummyfile.dat" may be a binary file . See it anyway? ^@^@^@^@^@^@^@^@ @^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ ^@^@^@^@^@^@^@^@ @^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ .... |
The -l option allows you to directly specify the size in MB or GB, making it easier than Windows
That's how to create an empty file of the specified size for each OS!
complete