LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-27-2013, 08:44 AM   #1
jismagic
LQ Newbie
 
Registered: Apr 2013
Posts: 1

Rep: Reputation: Disabled
Copy and verify a directory in Linux


Hello

I m transferring a folder from usb to local drive. I am using cp -r command to do it,
which works for me. But I want to verify if the file is transferred good.

I thought of 2 things - file size verification and CRC verification.

1, File size is different in usb drive and local drive - a few bytes different,
2. CRC verification is good.. but not sure how to do it..
I tried using cksum. is it OK to CRC a directory with cksum? If not, how i can
CRC all files in the directory?

3. Any other ideas?

thanks,
jis
 
Old 04-27-2013, 08:54 AM   #2
Sigg3.net
Member
 
Registered: Mar 2008
Location: Oslo, Norway
Distribution: Slackware 14.1 64-bit, Ubuntu 15.10, Fedora 17, Ubuntu 12 LTS and Ubuntu server 10.04
Posts: 168

Rep: Reputation: 23
Use 'sync' command to flush "temporary" data to disk. I always use this when transferring to USB devs.

Then, if you are paranoid, run md5sum on fileonpc vs fileonusb and see if the checksums are identical:
Code:
$ md5sum /home/file
123456767888999
$ md5sum /media/usb/file
123456767888999
This is just a mockup, but if the two numbers are identical the files are identical.

But if I understand you correctly, it's just about knowing that the data has actually been written. In that case, the sync command is your friend.

Last edited by Sigg3.net; 04-27-2013 at 08:56 AM.
 
Old 04-27-2013, 08:55 AM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
Try to copy the files again, this time with rsync and the -c option. rsync will compare source and destination files based on a checksum before it copies and skip files that are the same in source and destination. So if rsync does not copy a file you can be sure that the copy is not corrupted.
Example:
Code:
cp -r /source /destination
rsync -avc /source /destination
 
Old 04-27-2013, 08:57 AM   #4
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,252

Rep: Reputation: 313Reputation: 313Reputation: 313Reputation: 313
You can use md5sum for generating and checking:
Code:
md5sum /some_directory/* > checksum.md5
md5sum -c checksum.md5
 
Old 07-29-2014, 11:24 AM   #5
hans66
LQ Newbie
 
Registered: Jul 2014
Posts: 2

Rep: Reputation: Disabled
https://sourceforge.net/projects/crcsum/ has cp & mv with crc checksum
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Does Linux verify copy and save ? mistofeles Linux - Newbie 4 01-31-2012 07:33 AM
How can I use Linux to copy binary files to a new directory lnx_learner Linux - Newbie 1 01-07-2008 12:37 PM
verify directory creation shifter Programming 5 06-28-2007 03:28 AM
How do you GPG verify all of your rsync slackware directory Old_Fogie Slackware 31 10-24-2006 07:27 AM


All times are GMT -5. The time now is 08:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration