LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   MD5 of thumb drive is different than MD5 of image dd'ed onto it (https://www.linuxquestions.org/questions/linux-software-2/md5-of-thumb-drive-is-different-than-md5-of-image-dded-onto-it-4175581176/)

KenJackson 06-01-2016 07:55 AM

MD5 of thumb drive is different than MD5 of image dd'ed onto it
 
I have tried both these commands. (The file is intended for this purpose.)
Code:

dd if=file.img of=/dev/sdb bs=1M
dd if=file.img of=/dev/sdb

Then I check the md5sum:
Code:

md5sum /dev/sdb
dd if=/dev/sdb bs=1M | md5sum
dd if=/dev/sdb | md5sum

In all cases the md5sum of the device is the same, but it's different from that of the file.

Shouldn't they match?

michaelk 06-01-2016 08:25 AM

No. For example if the size of the image file is smaller then the flash drive you would expect the sum to be different because the dd command will not overwrite the entire drive.

The typical use for md5sum is to verify the integrity of the downloaded file. If the calculated sum matches the posted value then the file has not been changed due to the transfer process.

KenJackson 06-01-2016 10:40 AM

Ah! Good point.

This works. The count is the size of the file divided by 512. The result is the same as for the original file.
Code:

sudo dd if=/dev/sdb count=990915 | md5sum


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