copying a directory

copying a directory

Post by dl.. » Thu, 28 Sep 2000 04:00:00



I have copied a directory that contains files, subdirectories, and
softlinks with "find . -depth -print | cpio -pdmV /directoryname". When
I ran "cksum" and "sum" the output totals of the src and target were
not the same. Now when I add the "l" option to cpio I'm getting "cpio:
Cannot link "src/.../file.exe" and "/export/.../file.exe", errno 18,
Cross-device link".  Any idea why the "cksum" and "sum" totals would be
different from the src to target and the reason for the Cross-device
link error?

TY

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

copying a directory

Post by Arthur Darren Dunh » Thu, 28 Sep 2000 04:00:00



>I have copied a directory that contains files, subdirectories, and
>softlinks with "find . -depth -print | cpio -pdmV /directoryname". When
>I ran "cksum" and "sum" the output totals of the src and target were
>not the same. Now when I add the "l" option to cpio I'm getting "cpio:
>Cannot link "src/.../file.exe" and "/export/.../file.exe", errno 18,
>Cross-device link".  Any idea why the "cksum" and "sum" totals would be
>different from the src to target and the reason for the Cross-device
>link error?

Directories aren't copied.  They are recreated at the other end, with
potential differences.  They may be smaller is the main reason.

If the filesystems are different, they may have different block sizes.
--

Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                               San Francisco Bay Area
      < Please move on, ...nothing to see here,  please disperse >

 
 
 

copying a directory

Post by dl.. » Fri, 29 Sep 2000 04:00:00


The output from "du -sk" were also different, I would have thought they
would be the same.

Quote:> Directories aren't copied.  They are recreated at the other end, with
> potential differences.  They may be smaller is the main reason.

> If the filesystems are different, they may have different block sizes.
> --
> Darren Dunham


Quote:> Unix System Administrator                    Taos - The SysAdmin
Company
> Got some Dr Pepper?                               San Francisco Bay
Area
>       < Please move on, ...nothing to see here,  please disperse >

Sent via Deja.com http://www.deja.com/
Before you buy.
 
 
 

copying a directory

Post by Arthur Darren Dunh » Fri, 29 Sep 2000 04:00:00



>The output from "du -sk" were also different, I would have thought they
>would be the same.

You're going to have to give examples if you want any more from us.  I
already gave you some explanations.

2 directories may have the same name and have the exact same files in
them, but may have different sizes.
--

Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                               San Francisco Bay Area
      < Please move on, ...nothing to see here,  please disperse >

 
 
 

copying a directory

Post by dl.. » Fri, 29 Sep 2000 04:00:00


The src directory resides on a ~35G Metadisk and the target directory
is on a ~35G UFS on the same system, could this be the reason for the
different sizes?

Quote:> You're going to have to give examples if you want any more from us.  I
> already gave you some explanations.

> 2 directories may have the same name and have the exact same files in
> them, but may have different sizes.
> --
> Darren Dunham


Quote:> Unix System Administrator                    Taos - The SysAdmin
Company
> Got some Dr Pepper?                               San Francisco Bay
Area
>       < Please move on, ...nothing to see here,  please disperse >

Sent via Deja.com http://www.deja.com/
Before you buy.
 
 
 

copying a directory

Post by Arthur Darren Dunh » Fri, 29 Sep 2000 04:00:00



>The src directory resides on a ~35G Metadisk and the target directory
>is on a ~35G UFS on the same system, could this be the reason for the
>different sizes?

No.  If they're both 35G UFS, then they probably have identical block
sizes for file allocation.

The differences are probably in the size of the individual directories.
Is every file identical?
Is every target directory smaller than or equal to the source directory?
--

Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                               San Francisco Bay Area
      < Please move on, ...nothing to see here,  please disperse >

 
 
 

copying a directory

Post by Logan Sh » Fri, 29 Sep 2000 04:00:00



>The output from "du -sk" were also different, I would have thought they
>would be the same.

When you add files to a directory, the directory's size may be
increased if the space is needed.  When you delete files, the size is
not decreased (at least from my observations).

Thus, if you copy the whole directory to another place, a new directory
is created (although its mode, ownership, etc. may be updated to be
like the original), and it is the minimal size needed.  The other
directory may or may not be minimal depending its usage history, so the
sizes may differ.

If I am right, the "du -sk" output was only slightly different.

Another way that two trees might have different "du -sk" output even
with identical content is if there are sparse files in one or both of
them.  If you create a new file, write one byte, seek forward 100
megabytes, write one more byte, and then close the file, the OS only
allocates the blocks necessary to represent the bytes you wrote.  When
reading the file, all bytes in the middle of the two will show up as
zeros.  Some copy programs don't preserve this holey nature (since it's
extra work -- you have to detect sequences of zeros and then seek()
instead of writing them), and therefore the copies use the full amount
of space whereas the originals don't.  These types of files often
show up when you're using Berkeley DB, DBM, NDBM, GDBM, etc. files.

Hope that helps.

  - Logan

 
 
 

1. using find and copy to copy directories

 Hi,

 I am trying to copy some specific directories over to another
directory, using the find and cpio or copy commands. I am working in a
directory that is two directories above the directories that I need to
copy (I have to copy multiple directories within different
directories). Each dir structure looks like this:

  data(my working directory)
    |
  dir1
    |
  dir2
    |
  RAWdirectory(and contents)that-I-need-to-copy

 I tried doing this:

  find . -name '*RAW' -depth -print | cpio -pdumv target_dir/

 and I also tried this:

  find ././* -name '*RAW*' -depth -print | cpio -pdumv target_dir/

 These commands will copy the directories I need to the target
directory, but ALSO copy the two directories above each RAW directory,
which I do not want to copy. Does anyone know how to copy directories
that are *inside* other directories *without* copying the directories
that they are nested in?

       thanks,

           PC

2. Selecting media on D-Link DE-650 PCMCIA card?!?!

3. how to copy directory and sub-directory

4. LINUX to Windows CE handhelds?

5. copying a directory structure with a particular file in directories below

6. Command to change shell?

7. Q: copy directory (containing links) as directory (as files)

8. named src files

9. copying directories

10. How to copy a whole directory to another server

11. Copy newer files to a directory

12. copying whole directories CLI ftp client

13. How To Copy Only The Updated/New Files From One Directory To Another?