- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: cp -pr doesn't copy entire dir
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 03:55 AM
11-22-2001 03:55 AM
I am trying to copy directories from one lv to another using the cp command ( -pr params). The directories appear to have moved ok and it's only when I check using du -k that I notice that the size of the old and new dirs are different. Can anyone explain why this is happening or what I can do to resolve it.
Thanks for your help,
Donal
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 03:59 AM
11-22-2001 03:59 AM
Re: cp -pr doesn't copy entire dir
'cp -rp *' will not get .profile, .login, etc.
What User are you using? root?
Share and enjoy, Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 04:09 AM
11-22-2001 04:09 AM
Re: cp -pr doesn't copy entire dir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 04:12 AM
11-22-2001 04:12 AM
Re: cp -pr doesn't copy entire dir
cd /source
find . -depth | cpio -pvmdu /destination/.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 04:15 AM
11-22-2001 04:15 AM
Re: cp -pr doesn't copy entire dir
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 04:40 AM
11-22-2001 04:40 AM
Re: cp -pr doesn't copy entire dir
You could assure yourself that everything's copied across by running:
find directory ! -type d | xargs ll | awk '{TOT=TOT+$5}END{print TOT}'
find directory | wc -l
on the old and new directories and compare.
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 04:45 AM
11-22-2001 04:45 AM
Re: cp -pr doesn't copy entire dir
The source directories contain "empty spaces" where removed files once were registered. The target directories don't contain these empty spaces.
If cp doesn't return an error, it has worked fine.
If you insist to verify this, do the following :
find
find
If both instructions return are the same number, every file and directory has been copied.
Detailed verification can be done with the following instructions :
find
find
diff file1 file2
This returns you all differences is files and filesizes (including directorysizes).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 04:49 AM
11-22-2001 04:49 AM
Re: cp -pr doesn't copy entire dir
Why dont you try to locate missing files, if any.
Try this:
#tar cvf /tmp/d1.tar
#tar tvf /tmp/di.tar | wc -l
(this will give the count of all files and directories in
The count displayed on your source and destination should be same - if not, investigate the missing files.
If they are indeed the same, then you can have a warm fuzzy feeling that cp has done its job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 07:21 AM
11-22-2001 07:21 AM
Re: cp -pr doesn't copy entire dir
Directories size can vary, because the files in the new directories would not have the fragmentation which would be there in the files of the old directory. i.e the new directories should generally show LEsser space used than the old ones.
To copy directories , i normally prefer
the cd $SOURCE ;find . | cpio -pdlmuv $DEST ;
(easy to remember -> pdlmuv is PaDdLeMUV)
HTH
raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 07:34 AM
11-22-2001 07:34 AM
Re: cp -pr doesn't copy entire dir
Thanks again,
Donal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2001 08:00 AM
11-22-2001 08:00 AM
Re: cp -pr doesn't copy entire dir
Here's my 2 cents on the very good comments already made:
I formerly used:
tar cvf - . | (cd /new_dir; tar xvf -)
Then I read this reply by Bill Hassell:
The fastest way is to use the puddlemove options in cpio as in:
$ cd /source_dir
$ find . | cpio -pudlmv /destination_dir
Bill is right. cpio is much faster than tar.
About the du differences: as the number of files increase in a directory, the size of the directory entry must increase as well. It's kind of like filling up a sheet of paper with a list and having to add another sheet. That's why a newly created empty directory is smaller than one that has many files in it. The directory size does not decrease even after removing all files. You can erase lines from your list on the sheets of paper but you still have the same number of sheets. When you copy that directory, the destination directory is created small again and grows according to the number of files you have. Just like copying the list by hand, you start with a fresh sheet of paper and don't copy erased lines.
Make sense?
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2001 03:37 AM
11-23-2001 03:37 AM
Re: cp -pr doesn't copy entire dir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2001 03:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2001 03:52 PM
11-24-2001 03:52 PM
Re: cp -pr doesn't copy entire dir
find
find
find
find
The file count should be the same, the directory count might larger by 1 if the destination is a new volume due to lost+found directory.
The reason for smaller szes has been dicussed already (directory entries remain after the files are removed), but what if the destination is much larger?
The answer is: sparse files. These are files that are created with 'holes' in them. Consider creating a new file by writing record #1, then by using lseek, write record #1 million, then close the file. The rest of the intermediate records are never written and the directory will track just those two records.
However, Unix (it's friendly this way) will allow you to read this file equentially, but all the missing records will be full of zeroes. And this is what happens when the file is copied. So a 2 record file now becomes a 1 million record file and the destination is much larger. An common example of a sparse file is the core file.
Bill Hassell, sysadmin