Trying to make sure that the USB file is identical to source
Hello,
which command, switches You would use to make absolutely sure that the file copied to USB is identic to source file located on system drive? Code:
cmp -n `stat -c '%s' a` b Code:
sudo head -c $(stat -c '%s' a) b | sha1sum they say that due to kernerl Vm cache one should run "sync" un-mount usb drive: "umount /dev/sdX1" mount it again and then do mentioned cmp and sha1sum commands. Then sync and gracefully un-mount the drive. How you would do it? Should i prefix the checking command by "sync && " or something else? Linux type mentioned in signature. |
The quickest and most reliable way is to take md5sums of both files and compare them. If there is even one bit miscopied, the md5sums will be totally different.
|
Quote:
Code:
rsync -avP /path/to/file/to/be/copied /path/to/destination/directory/ Edit: Oh and the best part is if the file is to be copied many times due to changes in it then the rsync program will only copy the differences necessary to make them identical again. |
what about: cmp a b ?
but if you want to be sure the file is really written to the usb you need to execute sync first. |
Quote:
|
Quote:
Quote:
Quote:
Quote:
https://www.linuxquestions.org/quest...ze-4175538411/ https://www.linuxquestions.org/quest...nc-4175585087/ https://www.linuxquestions.org/quest...te-4175691912/ https://www.linuxquestions.org/quest...on-4175685524/ |
I like to be very simple about things. If I already know what to do, and it works, then I continue to do that.
There are some command forms for Unix or Linux which I've used for probably 30 years. Convincing myself to type something different is difficult, my finger memory literally types the, tried and true, by default. The commands cited in the OP, are ones which you've used. If they work, or if there are other commands you use to do this, I wouldn't look to change them to something you're unfamiliar with. Sorry this may be my misinterpretation, however I wouldn't be questioning the operation of some fairly long-time commands, cmp, sha1sum, and umount all work. |
"diff -b"
|
All times are GMT -5. The time now is 06:23 PM. |