How to create a large empty file in osx?
August 16, 2008 6:16 AM Subscribe
How do I create a very large (+10gb) empty file in OSX?
I've found some instructions on doing this through disk partitioning, but the external hard drive i have accessible right now has stuff on it - and i don't want to accidentally erase it all... i just want a large file full of zeroes.
I've found some instructions on doing this through disk partitioning, but the external hard drive i have accessible right now has stuff on it - and i don't want to accidentally erase it all... i just want a large file full of zeroes.
Alternatively, open Disk Utility, press "New Image", change the "Volume Size" to 10Gb, and save the resulting blank *.dmg file wherever you like.
posted by Popular Ethics at 10:26 AM on August 16, 2008
posted by Popular Ethics at 10:26 AM on August 16, 2008
How important is it that the whole file be zeros? A dmg is going to have some file system header stuff, even if the rest of the file is blank.
posted by Popular Ethics at 10:32 AM on August 16, 2008
posted by Popular Ethics at 10:32 AM on August 16, 2008
Response by poster: hrm, i was getting a "No such file or directory" in the terminal, and in the disk utility it wouldn't let me create the "New Image" (and didn't even give me the option of "Volume Size"), instead told me that the resource was busy. am i doing something wrong?
posted by greggish at 10:39 AM on August 16, 2008
posted by greggish at 10:39 AM on August 16, 2008
For those that these commands are arcane, I've also taken a large file that you would care that people saw the data from (a big picture or movie or application) and then copied it over and open again, stopping every once and a while to select more of the copies with "select all" until I fill up the disk. It's not as secure as dd or dedicated applications, but works in a pinch.
posted by bottlebrushtree at 10:45 AM on August 16, 2008
posted by bottlebrushtree at 10:45 AM on August 16, 2008
Best answer: i just tested claudius's thing (with a smaller count) and it works under OSX, but for some reason you have to specify the full path in "of=filename" part. specifying the path with ~ was giving me the same "No such file or directory" error, which i don't understand.
so putting of=/Users/greggish/Desktop/zeros.txt there will put the file on your desktop, for example.
posted by sergeant sandwich at 10:54 AM on August 16, 2008
so putting of=/Users/greggish/Desktop/zeros.txt there will put the file on your desktop, for example.
posted by sergeant sandwich at 10:54 AM on August 16, 2008
~ is expanded by the shell, not by the program called, and only at the beginning of a token:
posted by fantabulous timewaster at 12:07 PM on August 16, 2008
$ echo ~/foo; echo foo/~; echo of=~fooThis lets you use ~ in filenames.
/Users/rob/foo
foo/~
of=~foo
posted by fantabulous timewaster at 12:07 PM on August 16, 2008
If you just want to fill up the disk, dd is unnecessary. Good ol' cp will work file:
$ cp /dev/zero /path/to/big/file
I do this myself before disposing of old disks.
posted by chairface at 8:08 PM on August 16, 2008
$ cp /dev/zero /path/to/big/file
I do this myself before disposing of old disks.
posted by chairface at 8:08 PM on August 16, 2008
chairface: "If you just want to fill up the disk, dd is unnecessary. Good ol' cp will work file:
$ cp /dev/zero /path/to/big/file
I do this myself before disposing of old disks."
dd is much better, you can set the size of the file.
posted by zouhair at 11:01 AM on August 17, 2008
$ cp /dev/zero /path/to/big/file
I do this myself before disposing of old disks."
dd is much better, you can set the size of the file.
posted by zouhair at 11:01 AM on August 17, 2008
Actually, it's much easier just to use mkfile this way:
$ mkfile 10g /path/to/my/tengigfile
If you want it created sparsely, use the -n parameter.
posted by majick at 7:03 PM on August 18, 2008
$ mkfile 10g /path/to/my/tengigfile
If you want it created sparsely, use the -n parameter.
posted by majick at 7:03 PM on August 18, 2008
This thread is closed to new comments.
dd if=/dev/zero of=<filename> bs=1024 count=10485760
I believe that os x has dd installed, and had as a /dev/zero.
posted by claudius at 6:22 AM on August 16, 2008