[nylug-talk] Why is hardlink necessary?

Thomas P Brisco tpbrisco at gmail.com
Wed Dec 20 02:06:16 EST 2006


    Hi Yuskuke; nobody really answered this, and (I suspect) the real answer
is hidden in the ages of time.  Around 1985 or so, doing a soft-link lookup
required two hard-disk accesses -- in a period when that really mattered
(think 1984, 4.0BSD).  A hard-link is a direct reference to the inode on
disk, and
would thus fetch directly to the disk dereference in question.  A soft-link,
however, requires an initial request (to get the reference to a "real name")
and subsequent reference again to the disk to get the inode data.  A hard
link bypasses this.   Again; in about 1984/8 or so, this would matter -- in
modern
systems, the additional reference is not that big of a deal.   Soft-links,
however,
have the additional benefit of working between file-systems (which hard
links,
being tied to only the local file system, by inodes, can't handle) -- and so
brought
some great benefit to systems administrators (mind you; this is in a period
when a
"mv" between file systems would fail, but a "cp" would succeed -- this
apparently
works; since a "mv" merely relabels the existing inode, whereas a cp
replicates
the data).
    The difference, today, is probably more around some uber-nerdism that
you can shave 1/16th of a cycle (in a multiple operand world) on a disk
fetch.  I,
personally, also have a pereference for soft-links (which, frankly, dates to
a period when
this was more of a contentious issue) so that I more firmly understand when
a "rm"
is going to simply remove a disk reference and when it is going to actually
free up
disk space -- but, keep in mind, that even today, a hard-link _has_ to be on
the
same partition as the "original" file (the disk store) -- a soft link _may_
(or may
not) be on the same partition as the actual storage.  I honestly cannot
imagine why
(for any significant reason) something should be a hard link as opposed to a
soft
link in today's operating environment.
    -- Tom

----- Original Message ----- 
From: "Yusuke Shinyama" <yusuke at cs.nyu.edu>
To: "NYLUG discussion list" <nylug-talk at nylug.org>
Sent: Tuesday, December 19, 2006 5:52 PM
Subject: [nylug-talk] Why is hardlink necessary?


> Hi,
>
> This is just a question from curiosity.
>
> Recently I was looking around my filesystem and wondered why some
> packages (e.g. perl) are using hard links instead of symlinks.
>
> Well, maybe no one cares it as everything in the system is now
> managed by a packaging system, but I still want to know if there
> is some good reason, because I normally prefer symlinks rather
> than hardlinks to explictly show which file name is real and which
> is for compatibility. Also symlinks are good for backup.
> (With hardlinks, you would have to copy the same file twice.)
>
> To find hardlinks on your system, you can do the following:
>
>   $ find /bin /usr/bin /etc -type f -a '!' -links 1
>
> Thank you,
> Yusuke Shinyama
>
____________________________________________________________________________
_
> Hire expert Linux talent by posting jobs here :: http://jobs.nylug.org
> The nylug-talk mailing list is at nylug-talk at nylug.org
> The list archive is at http://nylug.org/pipermail/nylug-talk
> To subscribe or unsubscribe: http://nylug.org/mailman/listinfo/nylug-talk



More information about the nylug-talk mailing list