Copying or moving files to an NTFS partition changes the modified date of the file on Linux - Adventures in Switching to Linux

Sunday, March 2, 2008

Copying or moving files to an NTFS partition changes the modified date of the file on Linux

UPDATE 3/7/08: There is a fix thanks to Ubuntu Backports.
UPDATE 5/20/08: I wrote this post under Ubuntu 7.10. File modifications dates aren't being preserved under 8.10 either but for a different reason now.

I complained a while back about how copying files from my digital camera changed the modified date to the current time. Well now I can qualify that behavior a little more. It is a much more limited problem than I thought (though still a pretty big deal).

It appears that this only happens when copying a file to an NTFS partition. Ubuntu has only supported writing to NTFS partitions since release 7.10 (the current release I am running) thanks to NTFS-3G which has only been considered stable for a year (since February 2007) after 12 long years of development.

Want some proof and pretty screen shots? (I love some screen shots if you haven't noticed.) I created a file earlier today at 2:52:44 PM EST in my home folder on an ext3 partition.

The original file on an ext3 file system,
check out that modified date

Then I searched to see if I could find a work around, walked the dog and posted on Ubuntu Forums for help. Look at the subsequent accessed dates but the modified date that is intact.

Copying to another location on the ext3
file system retains the modified date

Copying to my external USB
FAT32 drive also works

But then I copy the same file to my NTFS partition. Look at that! Now the modified date is 4:15:15 PM EST instead of 2:52:44 PM EST like it should be and as it is when copying to ext3 and fat32.

But copying the same exact file to my old
My Documents folder on the Windows NTFS
partition changes the modified date! Argh!!

So how can I fix this? I don't know yet. I am not even sure if it is a bug or if it is just an unimplemented or misconfiguration. Either way, it is a problem. Lets hope someone in the Ubuntu forums has some ideas.

Ah, and after a little more research, this is in fact a known bug. #157396 - Copyng a file to a NTFS drive change the date and the time of the file Unfortunately it also doesn't look like there is much interest in fixing it.

UPDATE: It looks like there actually was a lot of interest in fixing it by the ntfs-3g developers. Wohoo! I think it was fixed in the November 20, 2007 release (release number 1.1120). Ubuntu 7.10 is running version 1.913 from September 13, 2007. I didn't have much luck upgrading to that release so I am not positive this fixes it but that is what the release notes make it sound like. Also, that is the release of ntfs-3g currently in the Hardy 8.04 repository.

But then it gets even better! (And by better I mean worse.) If I copy the file on the command line using the cp command then the modified date gets updated regardless of the destination partition, fat32 and ext3 included. This is unlike the copy in Nautilus where the modified date remains the same, as expected. Thanks for the consistency. UPDATE 2: It was pointed out to me that you can use the -p switch when using cp to preserve the mode, ownership and timestamps. Why isn't that the default?


Urs Naegeli said...

OK, let's go back to 7.04, this was a stable release of Linux ;-) I still have a CD burned...

The ubuntu users forums are now full of complaints about this, and apparently nobody cares. I do not hope that in the end we shall have to go back to the OS of the unmentionable from Redmond?!

Regards, Urs

Forrest said...

The problem this time is a bug in GVFS that is new in GNOME 2.22 and Ubuntu 8.04. The only work around I know of so far is using the command line and the -p switch when copying.