--link-dest on a local filesystem

Wayne Davison wayned at samba.org
Fri Mar 9 00:28:35 GMT 2007


On Thu, Mar 08, 2007 at 08:56:54PM +0200, Jaco Kroon wrote:
> For some strange reason, whenever I recreate the source file, even
> though it's identical to the old source file --link-dest simply does not
> create the link.

The file isn't identical enough to hard-link unless every preserved
detail is identical.  So, when using -a (which implies --times, as you
noted), the mtime has to be the same for the files to get hard-linked
together.  However, adding --no-times is not enough because rsync still
has to identify the file as unchanged, and that requires the file to
have the same size and mtime UNLESS you use the -c (--checksum) option.
Using -c, rsync will read each file, comparing the checksum, and then
hard-link any matches (as long as you aren't trying to set a conflicting
attribute on the destination file, such as mtime, permissions, group,
etc.).

Helpful hint:  Use -i (--itemize-changes) to see why rsync considers a
file to be different:  if it mentions the file's name in a link-dest
copy, the file is not being hard-linked.

This sequence of commands should work for you:

  mkdir a
  echo foo > a/tmp
  rsync -avi a/ b.1/
  touch a/tmp
  rsync -avic --no-t --link-dest=../b.1 a/ b.0/

..wayne..


More information about the rsync mailing list