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

[ale] link

On Apr 11, 2007, at 12:52 PM, Jeff Lightner wrote:
> When you create a (hard) link you're using the same inode as the
> original file so you're creating a separate name only.   This requires
> it to be on the same filesystem as the original.
> [...]
> Although inode is the same the space taken up by a hard link is the  
> same
> as that of a copy.   The benefit to link over copy is that changes to
> any of the links to the file are reflected in all of the links.   In a
> copy the change you make to one copy does NOT get reflected in any of
> the other copies until you recopy the original file again.

This bears repeating because I think the idea gets muddled in the  
next paragraph. The link is just another name for the same data (same  

> To save the space noted above you can use "ln -s" which creates a
> symbolic link.   The symbolic link uses only enough space for the
> pointer and name and has the added benefit that since it doesn't  
> use the
> same inode it doesn't have to be on the same filesystem.

This part is confusing. While an "ls" of the link shows the same size  
as the original, it is not actually taking up twice the space. A  
command like "du" which accounts for links will accurately reflect  
this. For example:

   $ ls -lA
   total 8332
   -rw-rw-r--  1 sc sc 8508884 Apr 11 15:20 x.tgz
   $ du
   8340    .
   $ ln x.tgz y.tgz
   $ ls -lA
   total 16664
   -rw-rw-r--  2 sc sc 8508884 Apr 11 15:20 x.tgz
   -rw-rw-r--  2 sc sc 8508884 Apr 11 15:20 y.tgz
   $ du
   8340    .

While "ls" thinks the size of the directory contents has gone from  
8332 to 16664, "du" sees no change in the size.