LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 07: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, 07: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: 173

Rep: Reputation: 28
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 07:56 AM.
 
Old 04-27-2013, 07:55 AM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
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, 07:57 AM   #4
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
You can use md5sum for generating and checking:
Code:
md5sum /some_directory/* > checksum.md5
md5sum -c checksum.md5
 
Old 07-29-2014, 10: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



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 06:33 AM
How can I use Linux to copy binary files to a new directory lnx_learner Linux - Newbie 1 01-07-2008 11:37 AM
verify directory creation shifter Programming 5 06-28-2007 02:28 AM
How do you GPG verify all of your rsync slackware directory Old_Fogie Slackware 31 10-24-2006 06:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:39 PM.

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
Open Source Consulting | Domain Registration