I have an SD card mounted by Lubuntu at /media/$USERNAME/COREELEC/

I need to copy a file from one directory to another and rename it. However if I check the md5sum (or sha512sum) after I unmount it and mount it again, it's different.

  • Why is the checksum different after mounting again the SD card?
  • Is there anything I can do to make it be the same again?

Steps to reproduce it (assuming there is an SD card mounted already by the OS)

Copy the file and check the md5sum for both the original and the copied files:

$ # copy the file from the original directory to the desired directory
$ cp /media/$USERNAME/COREELEC/device_trees/gxm_q201_3g.dtb /media/$USERNAME/COREELEC/dtb.img
$ # checksum of the original file
$ md5sum /media/$USERNAME/COREELEC/device_trees/gxm_q201_3g.dtb 
fd97f3d36cbb53cbdd59b53603f45913  /media/$USERNAME/COREELEC/device_trees/gxm_q201_3g.dtb
$ # checksum of the file I copied
$ md5sum /media/$USERNAME/COREELEC/dtb.img 
fd97f3d36cbb53cbdd59b53603f45913  /media/$USERNAME/COREELEC/dtb.img

Unmount the SD card

$ # check which drive to unmount
$ df -aTh | grep COREELEC
/dev/mmcblk0p1        vfat             512M  170M  343M  34% /media/$USERNAME/COREELEC
$ # unmount the SD card
$ umount /dev/mmcblk0p1

Unplug the SD card by hand and plug it again by hand waiting for the Operating System to automatically mount it.

Then check the md5sum (see now the checksum is different):

$ # checksum of the copied file (NOW DIFFERENT!)
$ md5sum /media/$USERNAME/COREELEC/dtb.img 
c8e06c372926719c0a0dac2d5b0f6ab5  /media/$USERNAME/COREELEC/dtb.img
$ # checksum of the original file (STILL THE SAME!)
$ md5sum /media/$USERNAME/COREELEC/device_trees/gxm_q201_3g.dtb
fd97f3d36cbb53cbdd59b53603f45913  /media/$USERNAME/COREELEC/device_trees/gxm_q201_3g.dtb
  • 1
    fix: change SD card. That's the symptom of a failing SD card. It's silent
    – A.B
    Nov 3, 2019 at 18:24

2 Answers 2


The md5 checksums of two files are different only if their content are different. You can confirm this by comparing them with cmp or diff command.

Their could be several reasons for the copy operation not working correctly:

  1. Unplugging sdcard before the disk cache is flushed. You can try using udiskctl.

  2. Filesystem corruption. You can try reformatting the card.

  3. Hardware failure.

  • My scenario was number 3: hardware failure. Replacing the unbranded/cheap SD card with a high quality one from a popular brand did the trick.
    – TPPZ
    Nov 6, 2019 at 15:30

System does not write all data until media is going to be unmounted. This is a common behaviour with removable (usually slow and flash memory) media because system try to limit writes.

Visually, you can notice file manager (PCManFM if I well remember...) warns you about wait for the unmounting process (if you have a LED for the SD card reader, it will blink like a hell)

EDIT1: you can check/prove my theory by using the sync command which flush file-system cache

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .