Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 28 Aug 2009 14:12:25 -0500
From:      "Rick C. Petty" <rick-freebsd2008@kiwi-computer.com>
To:        Aragon Gouveia <aragon@phat.za.net>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: some of my files have an incorrect block count
Message-ID:  <20090828191225.GA77462@keira.kiwi-computer.com>
In-Reply-To: <4A9822FC.2030606@phat.za.net>
References:  <4A9822FC.2030606@phat.za.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Aug 28, 2009 at 08:33:32PM +0200, Aragon Gouveia wrote:
> 
> I'm copying data across to a larger file system and in so doing, I've 
> noticed that some of the files in my old file system have an incorrect 
> block count.  After copying all data, df(1) reports that the new file 
> system has more data on it than the old one.  I've narrowed most of the 
> difference to one file in particular:

Yes, these are called sparse files.  Disk images are one example where
sparse files come in handy (although some argue that you should fully zero
an image initially to prevent fragmentation).

Many tools can handle sparse files efficiently.  You should read their
individual man pages.

> If dd(1) reads both files in, it counts the correct size, and running 
> md5(1) on both copies of the files produces the same hash, so at least 
> all the data is presumably present.

If you want dd to copy sparse files correctly, you need to specify
"conv=sparse" in the target dd command.  I personally prefer rsync with
"-S".

> Surely fsck(8) should detect this?

No.

> Is this inconsistency cause for concern?

No.  This is just how sparse files work.

-- Rick C. Petty



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