cp -pu NTFS problem

Branko bb.lis201 at internode.on.net
Thu Dec 9 14:34:47 CST 2010


I'm not completely confident about this but its worth a try...

How about mounting your NTFS with mount option "relatime" or similar.
Have a look at man page for mount for other options to try


On 09/12/10 12:26, Shane wrote:
> First time in a long long long time using Windows has been helpful ...
> on NTFS ctime is Creation Time, on Linux ctime is change time.
> 
> Since I've only got a Windows box here at work (sigh) I can't test
> this theory - but I'm guessing if you copy a file to NTFS partition /
> disk its ctime will get set to that time.  Modify the file a minute or
> two later, if I'm right the ctime won't have changed.  If this is the
> case, you should be able to just compare mtimes not ctimes (I kinda
> get why my mtimes confused me now ...)
> 
> Shane.
> 
> On 9 December 2010 12:12, Garry Trethewey <garrytre at bigpond.com> wrote:
>> Ok, thanks, now I know I'm in good company, and I have identified the
>> problem correctly and not missed something obvious.
>>
>> I'll look at git, and I'll look at a python script comparing source - dest
>> timestamp strings to replace cp -pu.
>>
>> regards Garry
>>
>>
>> On 09/12/10 11:22, Shane wrote:
>>>
>>> I run into this all the time - similar situation too ... I found that
>>> NTFS mounted on linux just doesn't like mtimes.  ctime comparison and
>>> updating worked fine, I'm yet to find a workaround to this either -
>>> quite painful problem really as it affects lots of *nix tools for
>>> backup - eg rsync, scp, cp ...
>>>
>>> My workaround have been to install git and push / pull / clone between
>>> home / work / usb.
>>>
>>> Shane.
>>>
>>>
>>> On 9 December 2010 11:06, Garry Trethewey<garrytre at bigpond.com>  wrote:
>>>>
>>>> Hi all
>>>>
>>>>
>>>> Problem
>>>> cp -pu doesn't seem to work properly with timestamps from an ntfs
>>>> partition.
>>>>
>>>> Just to remind people,
>>>> -p     same as --preserve=mode,ownership,timestamps
>>>> -u, --update copy only when the SOURCE file is newer than the
>>>> destination file or when the destination file is missing
>>>>
>>>> Here's the gory details.
>>>>
>>>> For a couple of years I've been doing
>>>> cp -puv -t $dest $source
>>>> from one ext3 partition to another, no problem.
>>>>
>>>> But now I've copied my whole data disk to an NTFS partition on a USB
>>>> portable hard drive. NTFS so I can use it at work.
>>>>
>>>> I want to copy files from this NTFS partition to an ext3 destination
>>>> with timestamps intact, so that next week when I do the same thing, I
>>>> only copy new or changed files.
>>>>
>>>>
>>>>
>>>> My code is
>>>> source=/media/data/aaa_S500_data/*    # the NTFS partition
>>>> dest='/home/garry/Desktop/junk'       # a ext3 partition
>>>> cp -puv -t $dest $source
>>>>
>>>>
>>>> Here is a demo source directory
>>>> garry at S500-lucid:~$ ls -l /media/data/aaa_S500_data/
>>>> total 64
>>>> -rwxrwxrwx 1 garry garry 38254 2010-12-02 06:20 elephantGreen.ico
>>>> -rwxrwxrwx 1 garry garry  5978 2010-10-25 17:27 elephant.ico
>>>> -rwxrwxrwx 1 garry garry    69 2010-11-30 05:55 readme.txt
>>>> -rwxrwxrwx 1 garry garry   766 2002-10-14 04:27 wdlogo.ico
>>>> -rwxrwxrwx 1 garry garry  5978 2010-10-25 17:27 wooly-mammoth.ico
>>>> garry at S500-lucid:~$
>>>>
>>>>
>>>> So into an empty directory, '/home/garry/Desktop/junk'  I copy
>>>> garry at S500-lucid:~$ cp -puv  -t '/home/garry/Desktop/junk'
>>>> /media/data/aaa_S500_data/*
>>>> `/media/data/aaa_S500_data/elephantGreen.ico' ->
>>>> `/home/garry/Desktop/junk/elephantGreen.ico'
>>>> `/media/data/aaa_S500_data/elephant.ico' ->
>>>> `/home/garry/Desktop/junk/elephant.ico'
>>>> `/media/data/aaa_S500_data/readme.txt' ->
>>>> `/home/garry/Desktop/junk/readme.txt'
>>>> `/media/data/aaa_S500_data/wdlogo.ico' ->
>>>> `/home/garry/Desktop/junk/wdlogo.ico'
>>>> `/media/data/aaa_S500_data/wooly-mammoth.ico' ->
>>>> `/home/garry/Desktop/junk/wooly-mammoth.ico'
>>>> garry at S500-lucid:~$
>>>>
>>>> Then without changing any files in $source, and if I do
>>>> cp -puv  -t '/home/garry/Desktop/junk' /media/data/aaa_S500_data/*
>>>> again, nothing should be copied.
>>>>
>>>> But the two files that were created / altered on the NTFS partition
>>>> _AFTER_ it got created with gparted&  partimage get copied again.
>>>>
>>>> garry at S500-lucid:~$ cp -puv  -t '/home/garry/Desktop/junk'
>>>> /media/data/aaa_S500_data/*
>>>> `/media/data/aaa_S500_data/elephantGreen.ico' ->
>>>> `/home/garry/Desktop/junk/elephantGreen.ico'
>>>> `/media/data/aaa_S500_data/readme.txt' ->
>>>> `/home/garry/Desktop/junk/readme.txt'
>>>> garry at S500-lucid:~$
>>>>
>>>> and again
>>>>
>>>> garry at S500-lucid:~$ cp -puv -t $dest $source
>>>> `/media/data/aaa_S500_data/elephantGreen.ico' ->
>>>> `/home/garry/Desktop/junk/elephantGreen.ico'
>>>> `/media/data/aaa_S500_data/readme.txt' ->
>>>> `/home/garry/Desktop/junk/readme.txt'
>>>>
>>>>
>>>> So it seems that cp -pu is recognising something that it needs to copy,
>>>> but not what it's supposed to.
>>>>
>>>> Have I conceptualised the problem correctly or is there something else
>>>> going on that I'm missing?
>>>>
>>>> Is there a fix or workaround?
>>>>
>>>> regards
>>>>
>>>> ------------------------------------
>>>> Garry Trethewey
>>>> ------------------------------------
>>>>
>>>>
>>>> --
>>>> LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.freenode.net
>>>> To unsubscribe or change your options:
>>>>  http://www.linuxsa.org.au/mailman/listinfo/linuxsa
>>>>
>>>
>>
>> --
>> ------------------------------------
>> Garry Trethewey
>> ------------------------------------
>>
>>
>>
> 



More information about the linuxsa mailing list