Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quickly create a large file on a Mac OS X system?

Tags:

macos

In order to create a 10 GB temp file...

In Linux you can do this:

fallocate -l 10G temp_10GB_file 

In Windows you can do this:

fsutil file createnew temp_10GB_file 10000000000 

...but what about if you're in OS X?

like image 218
fredrik Avatar asked Nov 07 '14 08:11

fredrik


People also ask

How do I make a large file on Mac?

To use the mkfile command, use the following general syntax: mkfile -n size[b|k|m|g] filename Using the above, to create a 2GB file called “TESTFILE” on the desktop, use the following command: mkfile -n 2g ~/Desktop/TESTFILE The file is created instantly and occupies the desired space on the disk.


1 Answers

macOS has the command mkfile to achieve the same:

mkfile -n 10g temp_10GB_file 

Syntax:

mkfile [ -nv ] size[b|k|m|g] filename ... 

And here's the related manual page for mkfile

Cross Platform Alternative (Unix including macOS):

As an alternative you could also you the Unix util dd:

dd if=/dev/zero of=temp_10GB_file bs=1 count=0 seek=10G 

Note that on macOS you need to use a lowercase for the unit as follow:

dd if=/dev/zero of=temp_10GB_file bs=1 count=0 seek=10g 

And here's the related manual page for dd

like image 143
reto Avatar answered Sep 28 '22 02:09

reto