Tar and hard links.
Ben Stringer
ben at burbong.com
Tue May 4 14:06:20 UTC 2004
On Sun, 2004-05-02 at 03:56, WipeOut wrote:
> How does tar handle hard links?? Is there a switch to use or does it
> handle them automatically??
>
> I looked through the man page and only saw a reference to symlinks but
> not hard links..
I was surprised by the answers saying tar would "efficiently" handle
hard links, so thought I would try it out. It was easy to confirm - I
used a copy of the "ls" as the contents of my first tarfile, then the
same executable and a hardlink to it in the second tar file. The 2
tarfiles are the same size, and a verbose table of contents on the
second tarfile shows tar is aware of the link.
Hope this is helpful to those interested.
Cheers, Ben
[ben at hillary hardlinktest]$ cp /bin/ls .
[ben at hillary hardlinktest]$ ls -l
total 80
-rwxr-xr-x 1 ben ben 76188 May 4 23:58 ls
[ben at hillary hardlinktest]$ tar cf t1.tar ls
[ben at hillary hardlinktest]$ ls -l
total 164
-rwxr-xr-x 1 ben ben 76188 May 4 23:58 ls
-rw-rw-r-- 1 ben ben 81920 May 4 23:58 t1.tar
[ben at hillary hardlinktest]$ ln ls ls2
[ben at hillary hardlinktest]$ tar cf t2.tar ls ls2
[ben at hillary hardlinktest]$ ls -l
total 328
-rwxr-xr-x 2 ben ben 76188 May 4 23:58 ls
-rwxr-xr-x 2 ben ben 76188 May 4 23:58 ls2
-rw-rw-r-- 1 ben ben 81920 May 4 23:58 t1.tar
-rw-rw-r-- 1 ben ben 81920 May 4 23:58 t2.tar
[ben at hillary hardlinktest]$ tar tvf t2.tar
-rwxr-xr-x ben/ben 76188 2004-05-04 23:58:23 ls
-rwxr-xr-x ben/ben 0 2004-05-04 23:58:23 ls2 link to ls
More information about the fedora-list
mailing list