Operating System - HP-UX
1827464 Members
5104 Online
109965 Solutions
New Discussion

How can I copy a sparse file ?

 
Jdamian
Respected Contributor

How can I copy a sparse file ?

Hi

I can create a sparse file. But when this sparse file is copied (cp command), the new file is not a sparse file.

How can I copy a sparse file so that new file be a sparse file too ?

Thanx in advance.
7 REPLIES 7
Massimo Bianchi
Honored Contributor

Re: How can I copy a sparse file ?

Hi,
usually i use "dd" to copy oracle datafiles, that are sparse files. I never had problems.

HTH,
Massimo

Jdamian
Respected Contributor

Re: How can I copy a sparse file ?

But new file is another sparse file or a regular file zero-filled ?

# echo A > f1
# dd if=f1 of=f2 bs=1024 seek=1024
0+1 records in
0+1 records out
# ll f?
-rw-r----- 1 root sys 2 Sep 8 12:07 f1
-rw-r----- 1 root sys 1048578 Sep 8 12:08 f2
# du -skx f?
1 f1
1 f2
# dd if=f2 of=f3
2048+1 records in
2048+1 records out
# ll f?
-rw-r----- 1 root sys 2 Sep 8 12:07 f1
-rw-r----- 1 root sys 1048578 Sep 8 12:08 f2
-rw-r----- 1 root sys 1048578 Sep 8 12:08 f3
# du -skx f?
1 f1
1 f2
1025 f3

I need f3 ocuppies the same disk blocks as f2.
Massimo Bianchi
Honored Contributor

Re: How can I copy a sparse file ?

More interesting question!

I think that you could try the GNU version of cpio, it supports sparse file handling...

http://hpux.connect.org.uk/hppd/hpux/Gnu/cpio-2.5/man.html

Massimo
Sยภเl Kย๓คг
Respected Contributor

Re: How can I copy a sparse file ?


dd is morethan sufficient.
instead of specifying dd if=f1 of=f2 bs=1024 seek=1024 this way use
#dd if=f1 of=f2
#ll

try like this
regards
SK
Your imagination is the preview of your life's coming attractions
Robert-Jan Goossens_1
Honored Contributor

Re: How can I copy a sparse file ?

How about prealloc a file ?

# prealloc 10MBfile 10485760

Robert-Jan
Jdamian
Respected Contributor

Re: How can I copy a sparse file ?

Hi

I searched in google and found

http://publibn.boulder.ibm.com/doc_link/en_US/a_doc_lib/aixbman/admnconc/sparse_files_under.htm

This page says that "cp", "mv", "tar" and "cpio" cannot preserver sparse allocation of a file.

Nevertheless, "pax" can ...

I tested... it's fine !
Ted Buis
Honored Contributor

Re: How can I copy a sparse file ?

It appears that pax only supports files <2GB. Did you ever find a solution to this that supports large files?
Mom 6