Home > News Tips

How to Make a File of a Certain Size on Mac?

Updated on Tuesday, August 27, 2024

iBoysoft author Sherry Song

Written by

Sherry Song
Professional tech editor

Approved by

Jessica Shee

English Français Deutsch やまと Español Português

Have you known that you can create a file of a specific size on Mac? So interesting, right? For various needs, such as testing storage limits, simulating data environments, or ensuring file system integrity, creating files of a certain size can be essential.

There might come a time when you need to create a file of a specific size, which can help you better manage disk space. On a Mac, there are several ways to accomplish this. This article will guide you through both the most convenient way to create a new file on Mac and make files of certain sizes with built-in tools.

How to Create Files of Specific Size on Mac?

The fastest way to create a new file on Mac

By default, Mac's context menu only includes the option to create a "New Folder" but not the option "New file". You have to open some apps to create your needed files, too cumbersome!!!

iBoysoft MagicMenu is a convenient tool, that enhances the Mac context menu by adding a "New File" shortcut. You can easily create various types of files: DOC, DOCX, XLS, XLSX, TXT, PDF....with it from the right-click menu on your desktop or within any open folder.

With iBoysoft MagicMenu, you no longer need to open specific apps, do so many actions, or use difficult commands to create a new file, why not download and save your cherishing time?

Create files of specific size on Mac with Terminal

Now let's learn how to create files of specific size on Mac. One Tool is Mac Terminal, which is suitable for those who are comfortable with command lines. Here, we can explore three commands dd, mkfile, and truncate to make a file of a certain size on Mac.

Command dd to create files of specific size on Mac

The dd command is a powerful utility for creating files with specific sizes. You can use it to create a file of a specific size on Mac filled with zeros or random data. (Here is an example to create a file named "testfile" of 100MB filled with zeros.)

  1. Finder > Applications > Utilities > Terminal.
  2. Type dd if=/dev/zero of=~/Desktop/testfile bs=1m count=100 
    if=/dev/zero: Input file is zero (file filled with zeroes). 
    of=~/Desktop/testfile: Output file path (this creates the file on your Desktop). 
    bs=1m: Block size (1 megabyte). 
    count=100: Number of blocks (100 blocks of 1MB each = 100MB). 
    Create file of specific size on Mac with Terminal
  3. Press the Enter key and wait.

If you want a file with random data, replace /dev/zero with /dev/urandom.

Command mkfile to create files of specific size on Mac

The mkfile command is simpler and specifically designed for creating files of a certain size on Mac.  (Here is an example to create a file named "testfile" of 100MB.)

  1. Finder > Applications > Utilities > Terminal.
  2. Type mkfile 100m ~/Desktop/testfile. 
    100m: File size (100 megabytes). 
    ~/Desktop/testfile: Output file path (this creates the file on your Desktop).
  3.  Press the Enter key and wait.

Then they fail, you can try the next command.

Command turncate to create files of specific size on Mac

The truncate command can also be used to resize or create a file of a specific size. (Here is an example to create a file named “testfile” of 100MB.)

  1. Finder > Applications > Utilities > Terminal.
  2. Type truncate -s 100M ~/Desktop/testfile. 
    -s 100M: Set the size to 100 megabytes. 
    ~/Desktop/testfile: Output file path (this creates the file on your Desktop).
  3. Press the Enter key and wait.

Please share these commands to help more people~

 

Create files of specific size on Mac with Disk Utility

For those who prefer a graphical user interface, macOS's built-in Disk Utility can be used to create disk image files(also called .dmg files) of a specified size.

  1. Finder > Applications > Utilities > Disk Utility.
  2. File > New Image > Blank Image.
  3. Select the parameters one by one. 
    (The Partition and Image Format remain the default settings.)
  4. Click Save to create the image file. 
    Create file of specific size on Mac with Disk Utility

Note this method can only create a .dmg file of a specific size on Mac. Share this post on your social platforms.

 

Conclusion

Creating files of a specific size on Mac is an easy process, whether you prefer using a graphical tool or Terminal commands.

For quick new file creation, iBoysoft MagicMenu offers the fastest way. Hope you can enjoy your digital life with Mac.