file size different from ls to du
Bruce Cran
bruce at cran.org.uk
Tue Jul 29 09:02:20 PDT 2003
On Tue, Jul 29, 2003 at 05:27:14PM +0200, Bogdan TARU wrote:
>
> Hi Drew,
>
> I have tried to create some files of myself, with 'spaces' in them
> (holes?), but they don't act like this. So could you please explain what
> 'sparse' means, and the 'trick' to create them?
>
Try using the 'truncate' utility:
truncate -s 102400G onehundred_terabytes
This will create a file which looks like it's 100TB though 'ls', but
which only uses 64KB in the directory usage via 'du'. Generally, creating
a file, seeking past the end of the file then writing something,
will create a 'sparse' file. This, when read, will appear
to contain zeros for all entries past the previous end of file,
to the entry which was written to.
--
Bruce Cran
More information about the freebsd-hackers
mailing list