[PLUG] Proper way to copy directories

Elliott Mitchell ehem at m5p.com
Thu Dec 23 03:05:30 UTC 2004


>From: Russell Senior <seniorr at aracnet.com>
> >>>>> "Elliott" == Elliott Mitchell <ehem at m5p.com> writes:
> 
> Elliott> Yes, those are four 1TB files there with interesting
> Elliott> named. Depending on the flavor of tar, it could take hours to
> Elliott> dump this, and it might well fail to fit onto the target
> Elliott> FS. tar might also fail to notice that those four are hard
> Elliott> links to each other.
> 
> GNU tar handles hardlinks and (with -S) sparse files.
> 
> Curious, will dump-restore work if you source and destination
> filesystems are different?

Yes. dump is filesystem specific, restore is not. If the destination
filesystem doesn't support features that the source filesystem does
though, you'll lose those features but otherwise everything works.

Things like permissions, hard links and sparse files have a well defined
API through the kernel and will always be preserved. Extended ACLs and
flags (such as ext2's nodump, immutable, append-only, etc) are only
guarenteed on the same type of filesystem. Large files may also be
truncated if the target doesn't support files that large.

>From: Russell Senior <seniorr at aracnet.com>
> >>>>> "Don" == Don Buchholz <buchholz at easystreet.com> writes:
> 
> Don> I remember core files on some Sun systems claiming to occupy
> Don> 100's of MB of disk, but after deletion, df would only show 10's
> Don> of MB freed.  No biggie until you try copying some users home
> Don> dirs using tar, and they suddenly blow up 10x in size!  tar-based
> Don> backup programs would have problems with this, too.
> 
> GNU tar with -S creates sparse-honoring archives.  For example, try:
> 
>   $ dd if=/dev/zero of=i-am-sparse count=1 seek=1023
>   $ ls -ls i-am-sparse
>   $ ln i-am-sparse i-am-spars2
>   $ ln i-am-sparse i-am-spars3
>   $ ln i-am-sparse i-am-spars4
>   $ tar -cSf /tmp/sparse.tar i-am-spars[e234]
>   $ pushd /tmp
>   $ tar xvf sparse.tar
>   $ ls -ls i-am-spars[e234]

It will still need to read a terabyte of zeros though.


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \   (    |         EHeM at gremlin.m5p.com PGP 8881EF59         |    )   /
  \_  \   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
    \___\_|_/82 04 A1 3C C7 B1 37 2A*E3 6E 84 DA 97 4C 40 E6\_|_/___/





More information about the PLUG mailing list