[CentOS] hard link a directory

Sun Jan 14 15:22:48 UTC 2007
Johnny Hughes <mailing-lists at hughesjr.com>

On Sat, 2007-01-13 at 08:46 -0500, William L. Maltby wrote:
> On Thu, 2007-01-11 at 23:08 +0100, Andreas Rogge wrote:
> > You can't.
> > Ken Thompson decided that this complicates things too much so this was
> > disabled back in the 70ies.
> > You can however do a
> > mount --bind /var/spool /home/recordings
> > this has a quite similar effect.
> 
> Not quite! See below.
> 
> > 
> > Regards,
> > Andreas Rogge
> > 
> > Am Freitag, den 12.01.2007, 05:50 +0800 schrieb Mark Quitoriano:
> > > Hi im trying to hard link a folder and i get this
> > > 
> > > # ln /var/spool /home/recordings
> > > ln: `/var/spool': hard link not allowed for directory
> > > 
> > > how do i hard link a directory?
> 
> What you really need to do is make a new directory and hardlink all the
> files from the original in the new directory.
> 
> This increments the link count for each file in the original directory
> (and so also, the new directory) so that an rm of one directory's file
> (s) just decrements the link count, removes the file entry in the
> appropriate directory and leaves the other directory's file entry alone
> (except for the reduced link count, which is not associated with the
> directory anyway) and leaves the underlying file contents in place.
> 
> This is not at all like a mount --bind.
> 
> One further "gotcha": when you replace the file in one directory by "mv"
> or "rm ; cp" etc., the other copy is left unaltered and it is easy to
> forget that the two "copies" are no longer the same.
> 
> Before the mv/rm/cp, etc. alterations to the file from either directory
> appeared in the other. This no longer occurs.
> 
> > ><snip sig stuff>
> 
> Forgive any errors, it's been decades.
> 

Also ... just for the record ... hardlinking is built into the copy
command:

cp -al dir1 dir2

(that will create a hard linked directory of files in dir2 that are from
dir1.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.centos.org/pipermail/centos/attachments/20070114/8ca7f717/attachment-0005.sig>