Do you want to create a large empty file for maybe testing purpose during disk access test ? Thankfully there is about three ways to create a large empty file on your Mac and we will cover them. With these three ways you will be able to quickly generate files of virtually any size, two will use the command line; one being operating system agnostic and the other OS X specific, and another more user friendly approach that utilizes the Disk Utility app native to Mac OS X.So let us start:
Create a Large File from the Command Line
The simplest way to instantly generate a large empty file is to use the ‘mkfile’ command, which can immediately create a file of any size, whether fairly small in bytes or huge in gigabytes. Syntax for mkfile is as follows:
mkfile -n size[b|k|m|g] filename
For example, to create a 1GB file called “LargeTestFile” on the desktop, the command would be:
mkfile -n 1g ~/Desktop/LargeTestFile
The file is created instantly and takes up the full size. Big files created from mkfile are full of zeroes.
The only downside to the mkfile command is that it appears limited to Mac OS X, thus if you’re looking for a cross-platform compatible solution that will work across other unix and linux variations you will want to use “dd” instead.
The dd command is a little less obvious to use than mkfile, but it’s stil fairly straight forward, you need to specify a file name, a block size, and a block count:
dd if=/dev/zero of=FileName bs=1024 count=1000
Another approach is to use the seek flag with some simple multiplication of a megabyte block size (1024), thus the following command would create a file that is 100MB in size (1024 x 100):
dd if=/dev/zero of=LargeTestFile.img bs=1024 count=0 seek=$[1024*100]
The latter multiplication method from CyberCit can be a bit easier if you’re not great at estimating large byte sizes.
Creating a Huge File with Disk Utility
Though most users looking to create large empty files are probably going to prefer the command line, you can also use Disk Utility.
- Launch Disk Utility and choose “New Image”
- Name the file as appropriate, then pull down the “Size” sub menu and select a file size appropriate for your needs
- Ignore all other settings and choose “Create”
So what do you think ?
[Tip via OSXdaily]