Copying files with holes in them, without filling the holes

Copying files with holes in them, without filling the holes

Post by Bill Irw » Tue, 18 Oct 1994 08:35:47

|+ but I do know that gnutar will do what you want.  I sus-
|+pect gnucpio will do as well.

|That's good to know!

No it's not.  Apparently the --sparse option of gnu tar doesn't
create archives with sparse files on some systems, SCO UNIX being

|Bill> Is it as simple as tar, with:
|Bill> cd /old/directory
|Bill> gtar --sparse -cf - . | (cd /new/directory; gtar --sparse -xvf -)
|       It should be, BUT ...
|       I tried this here and it dosen't work.  It turns out that the
|"sparse" option relies on a feature of BSD filesystems, and the code
|to handle sparse files when creating an archive is #ifdef'ed on a
|#define (BSD42) that isn't (and shouldn't) be defined when compiling
|for SCO.  Versions of GNU tar compiled for SCO (and some other OSes)
|will accept the --sparse option but will effectively ignore it.  These
|versions will extract a sparse file from a GNU tar archive, but they
|won't create an archive containing such a file.
|       Note that --sparse is only needed when creating the archive.
|It would be "a good thing" if versions of GNU tar built for platforms
|that don't support "--sparse" generated a warning saying "sparse not
|supported when creating/appending to an archive".
|       I looks like you'll have to find some other tool (or write
|your own) to deal with copying sparse files under SCO.  I could whip
|up such a program (or possibly a modification to GNU tar) pretty
|quickly if properly motivated (and I may do it anyway just to have
|around if I even need such a beast).

Back to the drawing board!  Does anyone know of a tool that works
on SCO UNIX sparse files?
Bill Irwin     -      The Westrheim Group     -    Vancouver, BC, Canada
uunet!twg!bill              604-431-9600 (voice) |     Your Computer  


1. Copying files with holes in them, without filling the holes

I have a large directory structure that needs to be moved to a
new, larger filesystem.  There are several files that are
indexed, which "ls" displays as being several megabytes in size,
but "df" recognizes that much of the file doesn't contain any

In other words, a "df" listing shows that there is 250MB free in
a 750MB filesystem, indicating that 500MB are used.  When this
data is copied to an empty 1GB filesystem using "tar", the df
shows there is only 20MB free, indicating that the data is
consuming 980MB.

Running "du -s" on the original directory reports that the disk
usage is about 980MB, which is larger than will fit on the old
750MB filesystem.  I have been advised that these large indexed
files get filled by programs such as "tar" when they are archived
and extracted.  I have tested copying a file with "tar", "cp",
"copy" and "cpio".  Each one produced a copied file that consumed
the amount of disk that the "ls" program indicated it should (as
determined by watching the "df" stats reducing).

The man page for "du" states that:

"Files with holes in them will get an incorrect block count."

The trick is:  how do you copy these files without filling in the
holes, so that it consumes the same amount of disk space in the
new filesystem as it did in the old one?
Bill Irwin     -      The Westrheim Group     -    Vancouver, BC, Canada
uunet!twg!bill              604-431-9600 (voice) |     Your Computer  

2. reentrant lex-yacc

3. Problem copying files with holes to msdos file system

4. Help! Problems installing Redmond Linux on Abit KT7A raid

5. Security Hole on webservers run on variuos OS, How to close UNIS hole

6. How to setup default color depth in X?

7. Black Hole / Sink Hole Routing

8. Firewall question

9. copy file with holes

10. Filling holes in ext2

11. holes in the files

12. File Permission (BUG/Security Hole?)

13. reiserfs, lilo, and 'hole found in map file'