The Need for Dummy Files
When you are setting up a new Mac, writing a custom AppleScript, or configuring a network backup system, you often need to test how the system handles large files.
If you want to know how long it takes to transfer 50 Gigabytes of data over your new Wi-Fi 6 router, or if you want to verify that your email client correctly blocks attachments over 25 Megabytes, you need a test file.
You could scour your hard drive for random 4K video clips and try to cobble together exactly 50GB, but that is tedious and imprecise.
Instead, macOS includes a built-in terminal utility specifically designed for this exact purpose: the mkfile (Make File) command. This tool can instantly generate a completely blank file of any precise size you specify, down to the exact byte.
Step 1: Understanding the mkfile Syntax
The mkfile command is incredibly straightforward, but it is unique to macOS and derived from its deep UNIX roots (you won’t find this exact command natively in standard Linux distributions).
The syntax requires only two pieces of information: the size you want, and the name of the file.
The Syntax:
mkfile [-n] size[b|k|m|g] filename
- b: Bytes
- k: Kilobytes (KB)
- m: Megabytes (MB)
- g: Gigabytes (GB)
Step 2: Generating a Standard Test File
Open the Terminal app (located in Applications > Utilities).
Let’s say you are testing a web portal that has a strict 10 Megabyte upload limit. You want to generate a file that is exactly 10MB to test the system.
Type the following command:
mkfile 10m ~/Desktop/upload_test.dmg
Press Enter. Instantly, a file named upload_test.dmg will appear on your desktop. If you right-click it and select “Get Info,” macOS will confirm it is exactly 10,485,760 bytes (exactly 10 Megabytes).
(Note: You can use any file extension you want—.txt, .zip, .dmg, or none at all. The file contains nothing but zeroes, so it doesn’t matter, but giving it a familiar extension can help it bypass basic system filters).
Step 3: Creating Massive Files for Stress Testing
If you are testing a Thunderbolt 4 external SSD and want to see how fast it can sustain a massive write speed, you need a massive file.
To create a massive 100 Gigabyte file on your desktop, run:
mkfile 100g ~/Desktop/massive_stress_test.tmp
Warning: Creating a file this large will take several seconds (or minutes, depending on your drive speed). The terminal will pause while it physically writes 100 billion zeroes to your SSD. Ensure you actually have 100GB of free space before running this command, or your Mac will throw a “Disk Full” error and could become temporarily unresponsive.
Step 4: The Speed Trick (The -n Flag)
If you do not want to wait for the Mac to physically write 100GB of zeroes, mkfile has a hidden trick.
By using the -n (non-allocating) flag, you can tell macOS to create a file that claims to be 100GB, but doesn’t actually contain any data yet. The operating system essentially reserves the name and the metadata, but leaves the physical disk blocks empty.
mkfile -n 100g ~/Desktop/fake_massive_file.tmp
This command will execute instantly. If you check “Get Info,” it will say the file is 100GB.
However, this is only useful for testing software quotas or directory limits. If you try to use this file to test transfer speeds, the system will realize the blocks are empty and will transfer the file instantly, ruining your speed test.
Step 5: Cleaning Up
Dummy files generated by mkfile are real files taking up real space on your hard drive.
When you are finished with your network or upload testing, remember to delete the files, especially if you generated Gigabyte-sized archives. You can drag them to the Trash, or delete them instantly from the terminal using the rm command:
rm ~/Desktop/massive_stress_test.tmp