How would I make dir2 a copy of dir1 w/hardlinks for the files?

Linda A. Walsh rsync at
Thu Mar 27 03:34:12 MDT 2014

Kevin Korb wrote:
> Hash: SHA1
> The rsync equivalent to cp -al would be:
> rsync -a --link-dest=/path/to/dir1 /path/to/dir1/ /path/to/dir2/
> Note that I switched to absolute paths since rsync considers
> - --link-dest relative paths to be relative to the target so the
> relative example would be: rsync -a --link-dest=../dir1 dir1/ dir2/
> which I think is stupid.
Well, stupid syntax or not, if it works, it will still be better than 
the current
state of cp which the devs are leaning toward not doing anything about --
they say it's the kernel's fault and they don't want to work around it 
on linux
if it is the kernel's fault.  Specifically, they rely on being able to 
hard link
to everything that not a directory -- symlinks, sockets, pipes, -- if 
you can't
hard link it, they don't want to support it.

They think it would be silly to work around a linux kernel bug (or 
feature some
might say) by creating a user symlink w/the same contents as the root-owned
symlink. the problems are related to the relatively new
/proc/sys/fs/protected_{hard,soft}links settings which seem to be on by 

While you can do some weird things with hard lines -- the claims of 
problems or
exploits around symlinks seem to be blown out of proportion -- the coredev
devel's don't believe it is exploitable, but that's really an aside. 
What is so,
is that they don't want to spend time working on it -- even though they 
that the code to do make copies is tehre on other ports to systems where 
hard links
don't work.

For some reason they don't see linux no longer supporting hard links to 
in various situation being the same as an OS that doesn't support them 
in the first
place.  My comment was if they don't work, it should link what it can and
make copies of the rest -- like they do dirs.
Oh well.. thanks for the heads up -- tried link-dest, but not using the 
parent dir --
I just gave it dir1, which didn't exist yet, and it complained about 
that and wouldn't
start the copy.

More information about the rsync mailing list