GNU bug report logs -
#5918
[dd] conv=sparse option
Previous Next
Reported by: Heinrich Langos <henrik-gnu <at> prak.org>
Date: Sat, 10 Apr 2010 00:33:02 UTC
Severity: normal
Tags: fixed
Done: Assaf Gordon <assafgordon <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On Sat, Apr 10, 2010 at 04:33:07PM +0100, Pádraig Brady wrote:
> On 10/04/10 01:28, Heinrich Langos wrote:
> > Hello Andreas, Samuel and list,
> >
> > sorry to pick up such an old thread, but I stumbled upon it while
> > looking for an efficient way to "re-sparse" files that contain a
> > lot of zero blocks but
> > 1) had already been expanded
> > or
> > 2) are being expanded due to pipes.
> >
> > On Sun, Dec 30, 2007 at 10:19:54AM +0100, Andreas Schwab wrote:
> >> Samuel Thibault <samuel.thibault <at> ens-lyon.org> writes:
> >>
> >>> Some time ago, I wrote a conv=sparse option for dd, attached is the
> >>> patch.
> >>
> >> How is it different from cp --sparse=always?
> >
> > I'd say in enough ways to make such an option highly desirable.
> >
> > a) "dd" will maintain an existing of=target file including the inode
> > number, thus respecting existing hard links. "cp" will depending
> > on the other options given (e.g. "-a") maintain or break existing
> > hard links to an existing target file.
>
> I don't think that's possible as holes can only be created at the end of a file.
> Well I think NTFS supports punching holes in the "middle" but it's not common.
>
> >
> > b) "dd" could read a stream from a device or stdin and write it directly
> > to a sparse file. no need to "dd" from e.g. a block device to a file and
> > afterwards do a "cp --sparse=always file sparse-file". this will save a
> > lot of disk space, io operations and time.
>
> This seems to work:
> cp --sparse=always /dev/stdin file
Yeap. That worked!
> hlangos <at> pc-hlangos:~/zaurus$ ls -lisa foo
> 958477 4 -rw-r--r-- 1 hlangos hlangos 3072 2010-04-13 12:12 foo
> hlangos <at> pc-hlangos:~/zaurus$ dd if=/dev/zero bs=1k count=100 | cp --sparse=always /dev/stdin foo
> 100+0 records in
> 100+0 records out
> 102400 bytes (102 kB) copied, 0.0802346 s, 1.3 MB/s
> hlangos <at> pc-hlangos:~/zaurus$ ls -lisa foo
> 958477 0 -rw-r--r-- 1 hlangos hlangos 102400 2010-04-13 14:06 foo
It doesn't change the target file's inode (and also maintains the existing
hard links).
Cheers
-henrik
This bug report was last modified 6 years and 228 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.