Showing posts with label copy. Show all posts
Showing posts with label copy. Show all posts

Tuesday, May 20, 2008

File modification dates changed in Ubuntu 8.04 on copy or move

Before upgrading from Ubuntu 7.10 to 8.04, I had the annoying problem of file modification dates getting changed when copying files to an NTFS file system. I also found that the problem was fixed in a newer version of ntfs-3g and all I had to do was get the package from the Ubuntu backports repository. Yipee!

But now I am running Ubuntu 8.04 and the problem has returned just in a new and nastier form. Now file modification dates are always updated in any move or copy, including ext3 to ext3! I did find that I could get around this problem when copying from the command line with cp using the -p switch to "preserve the specified attributes (default: mode, ownership, timestamps), if possible additional attributes: context, links, all". That didn't work for me when copying to an ntfs partition though. I got an error message: cp: preserving times for `/path/My Documents in Windows/testfile.zip': Operation not permitted

I could (and did) use sudo to make it work on ntfs though. I am glad there is a work around but I really do not want to have to drop to a command line every time I want to move or copy a file that I want the modification date preserved. I want to use Nautilus to drag and drop things!

I knew from my previous issue with ntfs that the copy command doesn't preserve the modification date by default but copying in Nautilus did and now it doesn't. There was a major change from 7.10 to 8.04 with the file system though. GNOME now uses GVFS instead of GnoneVFS (confusing similar names I know). And from my research, it looks like that is the problem. There are bug reports here (Ubuntu) and here (GNOME). Now let's hope it gets fixed for 8.04 and soon! Until then I guess I will be dropping to the command line to move my photos around, argh!

Friday, March 7, 2008

Why haven't I heard of Ubuntu backports before now?

I've been having the annoying problem of file dates not being retained when copying or moving files to an NTFS partition in Ubuntu 7.10. This has particularly kept me from transferring files from my digital camera in Linux because I don't want the file date lost and I don't want to put them on a non NTFS partition. It took me quite a bit of searching to figure out this was limited to a problem with NTFS and due to a bug in ntfs-3g. I also eventually found out that the problem in ntfs-3g has been fixed.

My problem at this point though was I could not find a way to get the new release installed. I didn't want to compile it myself. I found that a new version that fixed the problem was in the repository for the 8.04 release but attempting to install that didn't work due to other dependencies.

At some point, I heard about Ubuntu Backports.

The Backports team believes that the best update policy is a mix of Ubuntu's security-only policy AND providing new versions of some programs. Candidates for version updates are primarily desktop applications, such as your web browser, word processor, IRC client, or IM client. These programs can be updated without replacing a large part of the operating system that would affect stability of the whole system.
And it turns out a new release package of ntfs-3g that I need to fix my problem is right there in the backports repository. So now my problem is fixed and I still have a stable system. Nice!

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?