Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2008 22:48:42 +0200 (CEST)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        freebsd-stable@FreeBSD.ORG
Subject:   Re: Incorrect file size?
Message-ID:  <200806202048.m5KKmgo6073726@lurza.secnetix.de>
In-Reply-To: <g3gek1$22j$1@ger.gmane.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Ivan Voras wrote:
 > Rink Springer wrote:
 > > The 'vscan' user leads me assume this is SpamAssassin - I've seen this
 > > behaviour at work, where our scripts were trying to backup a 1TB file
 > > (which actually was ~vscan/.spamassassin/auto-whitelist). The result was
 > > that the backup script died due to lack of disk space on the backup
 > > server (as we don't use compression).
 > > 
 > > When I was investigating why the file could be so large it, it turned
 > > out the file was only a few hunderd 'real' MB's, so that is why I assume
 > > this person is having the same issue as we do. The file is a Berkeley DB
 > > file, by the way, so there's nothing textfile about it ;-)
 > 
 > I learn something every day :)
 > Didn't know BDB was smart enough to create sparse files.

BTW, you can use "ls -ls" to display the number of physical
blocks allocated to the file, so you can easily see whether
a file is sparse or not:

$ dd if=/dev/zero of=foo1 bs=1m count=1
$ truncate -s 1m foo2
$ ls -ls foo1 foo2
1040 -rw-------  1 olli  olli  1048576 Jun 20 22:43 foo1
  32 -rw-------  1 olli  olli  1048576 Jun 20 22:43 foo2

As you can see, the file size is the same, but the block
counts are different (I have BLOCKSIZE=K in my environment,
so the blocks are displayed in 1KB units).

I've written a small script that can be used to detect
sparse files (it even displays the "sparseness" percentage):

http://www.secnetix.de/olli/scripts/sparsecheck

Best regards
   Oliver

PS:  Of course it is still possible that a file system is
corrupt and needs fsck, no matter whether those files are
sparse or not.

-- 
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:  http://www.secnetix.de/bsd

"C++ is over-complicated nonsense. And Bjorn Shoestrap's book
a danger to public health. I tried reading it once, I was in
recovery for months."
        -- Cliff Sarginson



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