How to generate a large file allocating space

Alex Bligh alex at alex.org.uk
Sun Oct 31 15:34:44 UTC 2010


Matija,

--On 31 October 2010 17:19:49 +0100 Matija Nalis <mnalis-ml at voyager.hr> 
wrote:

> Well, some metadata will have to be written, but not data.
> shouldn't posix_fallocate(3) and/or fallocate(2) do that?
>
> I haven't got EXT4 around ATM, but IIRC it should work on it too.
> On XFS it seems to work too:

That's /almost/ perfect:

$ fallocate -l 1073741824 testfile
$ filefrag -v testfile
Filesystem type is: ef53
File size of testfile is 1073741824 (262144 blocks, blocksize 4096)
 ext logical physical expected length flags
   0       0 14819328           30720 unwritten
   1   30720 14850048           30720 unwritten
   2   61440 14880768           30720 unwritten
   3   92160 14911488           30720 unwritten
   4  122880 14942208            2048 unwritten
   5  124928 14946304 14944255  30720 unwritten
   6  155648 14977024           30720 unwritten
   7  186368 15007744           30720 unwritten
   8  217088 15038464           30720 unwritten
   9  247808 15069184           14336 unwritten,eof
testfile: 2 extents found

I think all I need do is clear the unwritten flag in each of the extents.
Else I think if I read the file using ext4 later (i.e. after I've
written directly to the sectors concerned) it will appear to be
empty. Any idea how I do that?

-- 
Alex Bligh




More information about the Ext3-users mailing list