Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Preserving file timestamps on NTFS partitions

  1. #1
    Join Date
    Aug 2009
    Beans
    6

    Preserving file timestamps on NTFS partitions

    This is driving me nuts. I'm using two NTFS formatted partitions. One is internal and holds all my data. The other is on an external hard disk and is where I back up all my data to. What I'd like to do is copy all my files from the data partition to the backup partition and preserve all the windows' timestamps (including the file creation dates).

    How hard can this be? Well it appears that in the case of Ubuntu the answer is very hard indeed.

    I'm aware that Linux does not support the concept of a file creation date natively. However, according to the ntfs-3g website, all of the windows' timestamps (including the creation date) are mapped on to the system.ntfs_times extended attribute (link). So if you preserve the extended attributes when making a copy then, in theory at least, the timestamps should also be preserved.

    I read on another forum that a file's timestamps will be listed (albeit in an unreadable hex format) if you run the following command:

    getfattr -h -e hex -n system.ntfs_times <filename>

    Unfortunately however, I just cannot get it to work. With every file I've tried I simply get a message saying "no such attribute".

    I would be grateful if anyone could help me.

    Thanks in advance.

  2. #2
    Join Date
    Apr 2010
    Beans
    29

    Re: Preserving file timestamps on NTFS partitions

    As far as I remember - when you copy / move files between devices - even in windows they get new creation dates. Not sure though...

    You can try to create a tarball of your files ( man tar / right click + compress - and choose .tar).
    Tarballs preserve timestamps - not sure if it wil work with ntfs - but it's worth a try...

  3. #3
    Join Date
    Nov 2009
    Beans
    Hidden!
    Distro
    Kubuntu 10.10 Maverick Meerkat

    Re: Preserving file timestamps on NTFS partitions

    You could also try the "cp" command with -p option
    or
    the "rsync" command with the "-X" option.

    For the complete command options, please refer to the man pages or google it.

  4. #4
    Join Date
    Aug 2009
    Beans
    6

    Re: Preserving file timestamps on NTFS partitions

    Quote Originally Posted by kblft View Post
    As far as I remember - when you copy / move files between devices - even in windows they get new creation dates. Not sure though...
    Indeed. Windows also has a very cavalier approach to timestamps.

    The reason why I need to preserve all timestamps is because I've got some photos on my hard disk and I use the timestamps to know when they were taken.

    Before I knew any better, I used to copy photos to my hard disk using either Microsoft's crappy camera wizard, or the standard Windows drag and drop copy. The trouble is that the two copy methods are inconsistent. One of them preserves only the creation date and the other preserves only the modified date! So I've got some files with a correct creation date, and some with a correct modification date.

    Ideally, I'd like some sort of utility that could go through all my files and set the modified date to either the creation date, or the modified date, whichever of the two is the earliest. I could then ignore the creation date altogether. However, until I've worked out a way to do that I'll have to live with preserving both dates.

  5. #5
    Join Date
    Nov 2009
    Beans
    Hidden!
    Distro
    Kubuntu 10.10 Maverick Meerkat

    Re: Preserving file timestamps on NTFS partitions

    Now, as far as the photos go, were they taken from a digital camera and then copied to the hard drive? If so, you could just point the cursor on the thumbnail/icon and it tells you when the picture was taken. This is because of the metadata that gets stored with the picture. Does this meet your requriements?
    There might be some tools out there to capture this date(such as febooti or setfiledate on windows).

  6. #6
    Join Date
    Aug 2009
    Beans
    6

    Re: Preserving file timestamps on NTFS partitions

    Quote Originally Posted by john newbuntu View Post
    Now, as far as the photos go, were they taken from a digital camera and then copied to the hard drive? If so, you could just point the cursor on the thumbnail/icon and it tells you when the picture was taken. This is because of the metadata that gets stored with the picture. Does this meet your requriements?
    There might be some tools out there to capture this date(such as febooti or setfiledate on windows).
    Yes I have considered that. It's definitely at least a partial solution.

    I actually came across a Linux utility a while back (unfortunately I can't remember its name) that converts a file's modified date to match the EXIF modified date. However, I'm not sure that all my photos have accurate EXIF dates embedded in them so I'd also like the additional security of being able to preserve the original NTFS timestamps as well.

  7. #7
    Join Date
    Oct 2008
    Beans
    286
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Preserving file timestamps on NTFS partitions

    Hi guys , this topic is similar with what I wanted to preserve the time stamps.Rather than preserve , i wanted to backup and reedit again.

    http://ubuntuforums.org/showthread.php?t=1448307

    I also hope someone would help me out to write a script for backup.
    Thank you

  8. #8
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: Preserving file timestamps on NTFS partitions

    @rastan, how are you mounting the partitions? Both with /etc/fstab? If so, please post your /etc/fstab.

    If you use the manual option at the partitioning stage of the live CD installer and get the installer to create an /etc/fstab entry, it does so with options that cause timestamps to be reset. The installer's line is of the form:

    Code:
    device     mountpoint     ntfs    defaults,nls=utf8,umask=007,gid=46    0  0
    It's the umask=007 and gid=46 that cause the problem - and they're completely superfluous anyway. But if you use a simple:

    Code:
    device     mountpoint     ntfs     defaults     0  0
    ... the problem goes away.

    More discussion on this thread:

    http://ubuntuforums.org/showthread.php?t=1330407

    This has been going on since Hardy. Yes, I have filed a bug report. Yes, it was ignored.
    Ubuntu 22.04 Desktop Guide - Ubuntu 24.04 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags

    Member: Not Canonical Team

    If you need help with your forum account, such as SSO login issues, username changes, etc, the correct place to contact an admin is here. Please do not PM me about these matters unless you have been asked to - unsolicited PMs concerning forum accounts will be ignored.

  9. #9
    Join Date
    Aug 2009
    Beans
    6

    Re: Preserving file timestamps on NTFS partitions

    Anyway, I've now found a partial solution. The problem was that Ubuntu comes installed with a very out of date version of the ntfs-3g driver. Disappointingly, even the version in the repository is out of date. So I went to the ntfs-3g site and installed their latest driver the old fashioned way (i.e. by running make on the command line).

    The getfattr command I mentioned earlier in the thread will now output the system.ntfs_times attribute as expected. Setfattr also works.

    However, there are still some annoying issues. All the standard Linux/Unix utilities such as cp and rsync appear to preserve the user extended attributes. However, they don't appear to be able to recognise the system entended attributes.

    getfattr and setfattr also appear to exhibit similar behaviour. You can read and write to a specific system attribute. But it's not possible to list the system attributes that are available.

    I'm not sure whether this restriction is standard and deliberate Linux behaviour, or whether it's just the way that the ntfs-3g driver has been written. But whatever the reason, it's extremely annoying, and it renders all the standard Linux utilities completely useless for my purposes.

    What I've managed to do to get round the problem is to use getfattr to dump all the system.ntfs_times parameters into a text file. Fortunately getfattr allows this to be done recursively over a range of files. Once the copying has been done, I'm then able to use setfattr to restore the parameters from the text file to the copied files. It works surprisingly well but it's clumsy. It's fine for archiving but I really don't want to have to go through that hassle every time I copy a single file from A to B.



    I have to say that this whole issue has left me feeling slightly disillusioned with Linux in general and Ubuntu in particular.


    The ability to copy files (and all their attributes) reliably and consistently is not something that's unusual and esoteric, it's a fundamental requirement for any modern operating system. Issues such as this will need to be addressed if Linux is ever to gain mainstream acceptance.


  10. #10
    Join Date
    Aug 2009
    Beans
    6

    Re: Preserving file timestamps on NTFS partitions

    Quote Originally Posted by ubfu View Post
    Hi guys , this topic is similar with what I wanted to preserve the time stamps.Rather than preserve , i wanted to backup and reedit again.

    http://ubuntuforums.org/showthread.php?t=1448307

    I also hope someone would help me out to write a script for backup.
    Thank you
    If you're able to read your original drive from Ubuntu, then what you're trying to achieve could be done using setfattr and getfattr. See the following link for further details.

    http://tg-linux.blogspot.com/2005/06...ttributes.html

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •