I have a set of files in which there are some hard links pointing to some of the files. For Example:
/tmp/test/file1
/tmp/test/file1_Link
The file1
is a file with size 1 MB.
file1_Link
is a hard link pointing to file1
When I use the unix tar
command to tar these both files , the resulting archive has a size of 1 MB (mytar.tar
)
tar -cvf ../mytar.tar .
-rw-r--r-- 1 bsarraf 189060905 1.0M Feb 11 22:06 mytar.tar
-rw-r--r-- 1 bsarraf 189060905 2.0M Feb 11 22:10 files.tar
However when I use the apache commons compress and add all the files in the tar file, I get a tar with size 2 MB (files.tar
).
This means in the tar the same file was added twice.
How can I add the hard link file in the tar as a hard link of the other file?