0

From Linux, if I alter files on an NTFS external HD so that I get some specific values for mtime, atime and ctime (readable with the stat command, and with ctime = mtime because one cannot change access permissions of files on NTFS from Linux - I think) and if I then connect the same external HD on a Windows 7 system, I see that Date modified = mtime (as expected) but I also get Date created = atime.

How comes atime takes the placeholder associated with the NTFS CTime timestamp, and is there a way to avoid this behavior, for example would using the noatime option on NTFS volumes be a proper solution? My goal is to be able to work from both Windows and Linux on this same external HD without mingling too much the timestamps.

Edit

After re-investigating the issue, it turns out that the problem is not present in the end. I must have been confused at the time I asked the question. I still leave the question as it has generated some comments and an answer.

The Quark
  • 270
  • 2
  • 12
  • But is it true that Linux really don't support creation time? – 炸鱼薯条德里克 May 17 '19 at 17:54
  • I think that you are talking about a serious inode change to make this happen. – mdpc May 17 '19 at 18:20
  • It's often a good idea to read existing Q&As before asking a question. https://superuser.com/a/703927/38062 https://unix.stackexchange.com/a/407305/5132 https://unix.stackexchange.com/q/7562/5132 https://unix.stackexchange.com/q/24441/5132 – JdeBP May 18 '19 at 00:22
  • @JdeBP: I had already read all those Q&As. My question is not 'how to make Linux support creation times', it is 'how to make it not use the creation time placeholder of NTFS to put atime values. – The Quark May 18 '19 at 06:45
  • You quite clearly have not read all of those, otherwise your question would not have the first sentence and third paragraph that it currently has. – JdeBP May 18 '19 at 11:54
  • @JdeBP: I see your point now. Thanks. I have rephrased the question. – The Quark May 18 '19 at 17:03

1 Answers1

0

This was too big to write as a comment, but I think it can help.

Well if you want to avoid this behavior, you can do something like this:

 $current_ctime=$(getfattr -n system.ntfs_crtime_be -e hex yourfile | grep system.ntfs_crtime_be | cut -d= -f2) 

Then after the changes restore the current_ctime using:

setfattr -n system.ntfs_crtime_be -v $current_ctime yourfile 

For multiple files, you can store for example all the ctimes using a for loop and restoring them in the same way for each file.

Not very beautiful but it works.