Queries-Meet1

4 views
Skip to first unread message

Tapan Avasthi

unread,
Feb 4, 2011, 1:16:05 PM2/4/11
to asig-bi...@googlegroups.com
Please put relevant queries here or here↓

ambarisha b

unread,
Feb 4, 2011, 3:39:07 PM2/4/11
to asig-bi...@googlegroups.com
Yeah, hardlinks can't be made across partitions.It creates ambiguous
inode references.This is what I got when I tried to verify a post I
found on googling.

$ touch f1
$ ln f1 f2
$ ls -i f*
3029234 f1 3029234 f2
$ ln -s f1 f3
$ ls -i f*
3029234 f1 3029234 f2 3029006 f3

Now you can see why hardlinks have a problem.As hardlinks have same
inode, the filesystem would have no way to check which filesystem the
inode under question points to.So to avoid this
you are not allowed to make hardlinks.Soft links as you can see don't
have a problem as their inodes are anyway different.

Regards
Ambarisha

kunreddy ramakrishna reddy

unread,
Feb 4, 2011, 4:11:07 PM2/4/11
to asig-bi...@googlegroups.com

Why would I ever use a hard link if I can use a soft link instead?

Answer:

(i)One can do a "ls -l somefile" and get a count of the hard links. Counting soft links is rough.

(ii) Hard links are co-equals. Unlink either of them and the data remains. A daggling softlink is worse than useless.

(iii) A related issue... "ln falsetarget somecopy" will fail if falsetarget does not exist. "ln -s" would not detect a problem.

(iv) It takes some time to travel down a symlink to the target. Hards links are a very little bit faster.

All that said, Better to prefer hardlinks to files in the same directory. ls -l /usr/bin to see what It means. Otherwise One can tend to go with soft links.

So Where does Softlinks are used in general :

Since you can't hard link between 2 different filesystems (mount points), you MUST use a softlink in those cases. 


Courtesy: Unix Forums
--
Ramakrishna Reddy K, 
M.E. Computer Science,
Project Assistant,CAHU,BITS-Pilani,Rajasthan.

Reply all
Reply to author
Forward
0 new messages