[Trilug-ontopic] I need to create a 2 gb file using Linux
Alan Porter
porter at trilug.org
Fri Dec 21 10:13:39 EST 2007
> Yeah, thanks, it worked great. Created a one gig file but it wasn't
> long before I got the file size I wanted. Thanks again!!!
Another trick... you can create a so-called "sparse" file by doing this:
dd if=/dev/zero of=/home/alan/myfile bs=1 count=0 seek=2G
That takes something like a millisecond to create. It does not waste
time copying 2 billion bytes to a file.
The space for the file is not actually allocated on the disk until some
actual data is written to it, and even then it is only allocated as
needed. If you read the file, it would look like all zeros.
This is useful if you just want to create an image for something without
waiting (for example, create an image and then immediately cover it up
with a filesystem or something). However, this method is NOT useful
when you're trying to test what happens when a disk is full, since it
does not actually fill up the disk.
Something neat to add to the toolbox...
Alan
.
More information about the Trilug-ontopic
mailing list