cpio and hard links

Victor Sudakov vas at mpeks.tomsk.su
Sat Aug 9 16:17:48 UTC 2014

Ronald F. Guilmette wrote:
> 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?

Try 'cpio -H ustar'.

Victor Sudakov,  VAS4-RIPE, VAS47-RIPN
sip:sudakov at sibptus.tomsk.ru

More information about the freebsd-questions mailing list