Why isn’t it possible to create hard links across file system boundaries?
A single inode number use to represent file in each file system. All hard links based upon inode number.
So linking across file system will lead into confusing references for UNIX or Linux. For example, consider following scenario
* File system: /home
* Directory: /home/vivek
* Hard link: /home/vivek/file2
* Original file: /home/vivek/file1
Now you create a hard link as follows:
$ touch file1
$ ln file1 file2
$ ls -l
Output:
-rw-r--r-- 2 vivek vivek 0 2006-01-30 13:28 file1 -rw-r--r-- 2 vivek vivek 0 2006-01-30 13:28 file2
Now just see inode of both file1 and file2:
$ ls -i file1
782263
$ ls -i file2
782263
As you can see inode number is same for hard link file called file2 in inode table under /home file system. Now if you try to create a hard link for /tmp file system it will lead to confusing references for UNIX or Linux file system. Is that a link no. 782263 in the /home or /tmp file system? To avoid this problem UNIX or Linux does not allow creating hard links across file system boundaries. Continue reading rest of the Understanding Linux file system series (this is part VII):
- Part I - Understanding Linux superblock
- Part II - Understanding Linux superblock
- Part III - An example of Surviving a Linux Filesystem Failures
- Part IV - Understanding filesystem Inodes
- Part V - Understanding filesystem directories
- Part VI - Understanding UNIX/Linux symbolic (soft) and hard links
- Part VII - Why isn't it possible to create hard links across file system boundaries?
E-mail this to a friend
Printable version
You may also be interested in other helpful articles:
- Understanding UNIX / Linux symbolic (soft) and hard links
- Comparison Linux vs UNIX file systems
- Understanding UNIX / Linux filesystem directories
- Understanding UNIX / Linux filesystem Superblock
- Understanding UNIX / Linux filesystem Inodes
Discussion on This Article:
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: internal_data_structures, linux filesystem, ln command, ls command, metadata structure, superblock, unix filesystem



Hi,
I wants to know that where are the links store?,is it created automatically at the time of creating the new file?Is it store in the inode or special file created for directory?
what is different between the links and link count?
regard
Debakanata
this example was confusing
because you are using
the same name
for the files
and
for the paths
Answer is good but simply say “Another name to same file”with same inodes.