Re: Tar and hard links.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2004-05-04 at 10:06, Ben Stringer wrote:
> 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@hillary hardlinktest]$ cp /bin/ls .
> [ben@hillary hardlinktest]$ ls -l
> total 80
> -rwxr-xr-x  1 ben ben 76188 May  4 23:58 ls
> [ben@hillary hardlinktest]$ tar cf t1.tar ls
> [ben@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@hillary hardlinktest]$ ln ls ls2
> [ben@hillary hardlinktest]$ tar cf t2.tar ls ls2
> [ben@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@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
I think the key here is the difference between hard and soft links.

Hard links point to the inode (the actual file), whereas soft links
point to a given name of the file (which may have more than one name or
link). 
-- 
jludwig <wralphie@xxxxxxxxxxx>



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux