Ubuntu 20.04 messes up file modification dates on exfat file systems

Somehow related to my previous post: As of currently – i.e. September 2020 – there is a weird bug in Ubuntu 20.04’s exfat support: When you mount an exfat file system (like the one on pretty much any MicroSD card that you would use in a GoPro), it will not only show all files as exactly one month into the future, but it will even change the modification date to that one month in the future. Thus, if you mount an exfat filesystem two times in a row, all files will have a modification date two months in the future. Very annoying.

Luckily there is an easy workaround: Instead of the built-in (kernel module?) exfat support, just install the packages ‘exfat-fuse’ and ‘exfat-utils’ (i.e. type sudo apt install exfat-fuse exfat-utils in the shell). Once you mount the MicroSD card again, it will be mounted using the fuse driver, which does not mess up the modification dates.

Those dates that have already been messed up though, need to be fixed. I’ve created a small script that can do that. Download it (here), chmod +x it and then run it with the file name(s) of the affected files as parameter(s). If the date has already been messed up to more than one month into the future, just run the script multiple times.

7 thoughts on “Ubuntu 20.04 messes up file modification dates on exfat file systems”

  1. Hello Patrick, now something else happened. With last sunday time change in France when I compare the file on my usb key and the files on my hard drive, the files on my hard drive went back 1h. So that I have to potentially synchronize huge amount of data again. Is there a way to tell ubuntu keep the files time the way they were and not have time change affect them? Would appreciate if you could help.

    1. Hi Alexandre, I don’t really know what happened there. I just googled a bit, and it looks like exfat should store the timezone in the file meta data, which means what you’ve described should usually not happen.

      When France switched from Central European Summer Time (CEST) to Central European Time (CET), did you change the system time of your computer manually, and left the time zone at ‘CEST’ by any chance? That’s the only scenario that I can think of, where now the timestamps of your files on the exfat file system would show up with a one hour time difference.

      I’ve checked the files on my SD card from before the time change (I’m in Germany, i.e. we’re in the same time zone, and we switched from summer to winter time on the same day), and their timestamps look fine. Dolphin (my file manager program) also shows the correct time zone in the meta data view.

    2. Oh, it just occurred to me, there is another possible scenario: Maybe the device / machine that created the files on your file system was / is using a time zone that does not make the summer -> winter time switch – e.g. UTC (commonly used on servers, for example).

      In any case, it’s pretty easy to change the timestamps of the files (and also the timezone), using the ‘touch’ and the ‘date’ commands. You can have a look at the script I linked from the article. With the help of the man pages of the ‘date’ command you should be able to figure out how to change either by one hour, or change the time zone. If you need help, please let me know.

Leave a Reply

Your email address will not be published. Required fields are marked *