3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Why can't directories be hard-linked on Unix filesystems (e.g. HFS)?

On both my MacBook (OS 10.5.8) and Linux (RHEL4) I've tried to do some directory organiztion using hard links (ln, not ln -s). When I try to hard-link a directory, I get an error message:

{yakut05:81} mkdir tempo
{yakut05:83} ln tempo tempo-link
ln: `tempo': hard link not allowed for directory
{yakut05:84} 

The man page for ln doesn't specify this limitation. I wonder if any filesystem gurus out there could explain why it's not allowed? I'm sure it has to do with the inode structure, but I'd like to be clear on the details.


13 answers
sort by: active | newest | oldest
Mar 10, 2010. 4:53 PMseandogue says:
afaik, can't be done. see

http://developer.apple.com/mac/library/technotes/tn/tn1150.html#HardLinks
Mar 10, 2010. 11:12 PMlemonie says:
If I just hit the link button and paste into the little box it works for me.
developer.apple.com/mac/library/technotes/tn/tn1150.html#HardLinks

L
Mar 11, 2010. 1:04 PMlemonie says:
Yea, the new editor didn't come with instructions (as far as I know). Still knowing some HTML is handier than it used to be.

L
Mar 11, 2010. 6:28 PMseandogue says:
I failed to abide by the editor and hit post-comment...got lazy didn't redo it....the shame, the mortal shame ;)
Mar 11, 2010. 6:31 PMseandogue says:
;)

I know. I was too tired to go back  and copy past edit the note... The particular plugin they use (or it appears to be the same one) is quite popular, but very clumsy and slow imo.The first time I encountered that editor plugin, I was excited by the possibilities, but equally dissapointed once I used it.. Sorry for the glitch...figured you'd understand. I don't usually do that, btw, just too lazy when I posted.

Total paraphrasing. I'm usually disinclined to commenting by copy-out (clone the results of a net search), but the occasional one doesn't violate values... I have zero experience with macs...well, aside from machine level programming on the first ones (Apple IIE I believe) during engineering course work nearly 30 years ago...but, the question was legit, had merit (imo), was interesting, and seemed like it ought to have an obvious reason, coupled with my foreknowledge that you would already have performed some search...two eyes often better than one in those cases...I rad enough to confirm the logic and figured you'd missed it along the way.I blather. must get some sleep.
Aug 27, 2011. 6:43 PMganglion says:
I think this is a deliberate design choice, not a bug. If hard linked directories were allowed, then you would have the possibility of creating circular loops in the filesystem structure. This make it much harder for filesystem search algorithms to produce a comprehensive list of files and directories under a certain point.

With a hard link, there is literally no difference between one link name and the other - they are both pointers to inodes - so the search algorithm would have no way of knowing which was the 'real' name and which was the link.
Aug 27, 2011. 10:32 PMganglion says:
Yes - that's why you can only soft link directories.

I'm glad this was useful - I found the comment from last year after looking your page, and I wasn't sure whether you would have forgotten about it or found the answer anyway.
Mar 10, 2010. 3:35 PMlemonie says:
You won't have overlooked anything obvious or made any basic error. Might the permissions or path be "funny" on the target drive / directory?

L

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!