[Novalug] terminology question 0-filled holes

Mark Smith mark@winksmith.com
Sun Aug 5 18:45:23 EDT 2012


aside... that was a fun prank senior operators used to play on young
operators.  it's easy to create a 100GB file on a 250MB file system and
just sit back and watch the look on the young pups face when the backup
system requests you to set aside several hundred tapes for the backup.


On Sun, Aug 05, 2012 at 06:34:45PM -0400, John Franklin wrote:
> 
> On Aug 5, 2012, at 4:47 PM, Bonnie Dalzell wrote:
> > hmm - what is a zero filled hole (0-filled)
> 
> It's another term for a "sparse" file.  If a block has all zeros in it, then there is no point in allocating that block on disk.  Rather the filesystem notes which blocks have all zeros in them in the inode and (if read) returns a buffer full of zeros.
> 
> They're most commonly used in:
> 
> * scientific computing where there are large data sets with large blocks of zeros at various points (think sparse matrix)
> * Disk images for VMs with little to nothing in them (yet)
> * Some process accounting files
> 
> The last happens where each record is a set size and indexed by UID or something.  If you have a large enough gap in UIDs, then the file would have lots of blank space.  Assume the record is 1k, and you have a user with UID 10000, all other users are under UID 500.  Then between 500 and 10000 there would be 9,500 blank records.  If the filesystem fills them all in, it would take an extra 9.5M (ish) of space to store records for users that don't exist.
> 
> You can create a sparse file with:
> 
> 	dd if=/dev/zero of=mysparsefile seek=1024 bs=8192 count=1024
> 
> And a non-sparse file with:
> 
> 	dd if=/dev/zero of=mynotsparsefile bs=8192 count=2048
> 
> Both of them will be 16M in size, but the first one will take up half the blocks.  You can see how many blocks a file has allocated to it with ls -s
> 
> vmadmin$ ls -sl my*
> 16384 -rw-rw-r-- 1 vmadmin vmadmin 16777216 Aug  5 18:29 mynotsparsefile
>  8192 -rw-rw-r-- 1 vmadmin vmadmin 16777216 Aug  5 18:29 mysparsefile

-- 
Mark Smith
mark@winksmith.com
mark@tux.org



More information about the Novalug mailing list