Operating System - HP-UX
1834768 Members
3918 Online
110070 Solutions
New Discussion

Coping data from one file system to other file system?

 
Insu Kim
Honored Contributor

Coping data from one file system to other file system?

After copying data from one file system to other file system, how can I verify that every data has been copied without any problems ?
Sometimes, bdf shows a slightly differnet output, that is, it looks like data has been shrinked.

Thank you for your help.
Never say "no" first.
9 REPLIES 9
federico_3
Honored Contributor

Re: Coping data from one file system to other file system?

you can compare the directories using diff:

see:
man diff


federico
A. Clay Stephenson
Acclaimed Contributor

Re: Coping data from one file system to other file system?

Hi,

If you want to be absolutely, positively sure then use the cksum command on both the original and copied versions of each file and directory.

You could drive it with a find -exec statement on the original filesystem for each file/directory to
1) cksum origfile > /tmp/f1
2) cksum copyfile > /tmp/f2
3) diff /tmp/f1 /tmp/f2

This will account for every byte in the original filesystem.

Regards, Clay

3)
If it ain't broke, I can fix that.
Vincenzo Restuccia
Honored Contributor

Re: Coping data from one file system to other file system?

1) sum origfile > /tmp/f1
2) sum copyfile > /tmp/f2
3) sdiff /tmp/f1 /tmp/f2
See man sdiff and sum.

Mladen Despic
Honored Contributor

Re: Coping data from one file system to other file system?

In-Su Kim,

You can use:

dircmp -s $dir1 $dir2

If you receive no output, the directories $dir1 and $dir2 are identical.

HTH

Re: Coping data from one file system to other file system?

Kim,

This generally happens when you have different file system size due to the metadata structures, etc.

You can try du -sk on the directories and if the match close enough , it should be alright.

Sundar.
Bill Hassell
Honored Contributor

Re: Coping data from one file system to other file system?

The sizes of files and directories that are copied from one directory to another will almost always be different! But that's OK since the reason relates to how data is stored.

When you create a new directory, it has very few slots to hold names so it must be expanded to hold new names. If a directory is filled with hundreds or thousands of names, then most of the names are removed, the directory will be shown as having a large size (with ls -ld) but only a few files--the directory does not return the empty name slots. Thus, a copy of a directory will be significantly smaller because the unneeded slots are not created. But the copy is just fine even though the occupied amount of space is smaller.

On the other hand, copying files may result in a larger copy. This is due to sparse files. All Unix system can be directed to create a sparse file by writing an inital record, then, using lseek(2), writing record number 1 million. The files contains 2 records with a million imaginary spaces in between so the file is small on the disk.

But copy this file serially (it was never created serially) and all the missing (undefined) records are supplied as a stream of zeros, thus the copy is significantly larger. The most common sparse file is a core dump which can have empty spaces where gaps in the memory allocation exist. Now the file is identical to any program that reads the data whether it is the original or larger copy--they produce the same exact records when read by an application.

Note also that cksum is a good way to verify files and will produce the same result for sparse files and their copies.


Bill Hassell, sysadmin
Scott_14
Regular Advisor

Re: Coping data from one file system to other file system?

Hello:

If your copying to a newly created file system, I beleive you could use a bdf -i, and compare the inodes. I have done that
when copying file systems, and made sure that they match up, which tells me all the files I intended to copy indeed copied.

scott
Ralf Hildebrandt
Valued Contributor

Re: Coping data from one file system to other file system?

The right tool for that kind of job is rsync (www.rsync.org)
Postfix/BIND/Security/IDS/Scanner, you name it...
CHRIS_ANORUO
Honored Contributor

Re: Coping data from one file system to other file system?

Hello,

You can copy using find and cpio in this form:
Change Directory (cd) to the directory to be copied
Then "find . -depth -print| cpio -dump /target directory"
Then use wc command to verify the number of characters and words copy with the original.
If you have large files use bdiff, instead of diff.
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.