Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Jul 2003 17:02:15 +0100
From:      Bruce Cran <bruce@cran.org.uk>
To:        Bogdan TARU <bgd@icomag.de>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: file size different from ls to du
Message-ID:  <20030729160215.GA3822@buffy.brucec.backnet>
In-Reply-To: <20030729172615.N13255-100000@fw.office.icom>
References:  <200307291524.h6TFO3J06998@revolt.poohsticks.org> <20030729172615.N13255-100000@fw.office.icom>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030729160215.GA3822>