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 |
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 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. |
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 |
You can use md5sum for generating and checking:
Code:
md5sum /some_directory/* > checksum.md5 |
https://sourceforge.net/projects/crcsum/ has cp & mv with crc checksum
|
All times are GMT -5. The time now is 07:53 AM. |