cpio and hard links

Ronald F. Guilmette rfg at tristatelogic.com
Sun Jul 27 21:12:29 UTC 2014



Given a directory "tmp" which contains two files, "foo" and "bar",
both of which are merely hard links to one another, the following
command will, apparently, produce an archive of the directory in
question which contains only a single instance of the actual file
contents:

	tar cvf tmp.tar tmp

The resulting tmp.tar file can later be unpacked, using tar, resulting
in a directory structure which exactly mirrors the original "tmp"
directory, including preservation of the hard link(s).

I note however that, given the same original directory structure, the
following command generates an archive file containing two complete
instances of the file data:

	find tmp -depth -print | cpio -ovm > tmp.cpio

For the the cpio program that is part of FreeBSD, is there any option
which would have the effect of causing cpio to only archive a single
instance of the data associated with each unique inode... as tar apparently
does, by default?

(If any such option exists, my hasty perusal of the relevant man page
did not reveal it.  My apologies if I simply missed it.  In that case
I shall certainly, happily, and humbly attempt to RTFM once again and
more carefully.)


More information about the freebsd-questions mailing list