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


-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
$ ls -i file2

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?

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 14 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
14 comments… add one
  • Debakanta Jan 20, 2007 @ 7:07

    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?


  • nobody Mar 3, 2008 @ 14:11

    this example was confusing
    because you are using
    the same name
    for the files
    for the paths

  • franklin Aug 4, 2008 @ 7:34

    Answer is good but simply say “Another name to same file”with same inodes.

  • rewt Dec 16, 2008 @ 17:15

    Your /tmp example above assumes that a novice-user already knows the difference between ‘filesystems’ . This term is used interchangeably and the meaning depends on the context where[how] it’s used.

    /tmp above implies it’s on a different partition (and may be possibly another filesystem(ext2 rather than ext3(/home)).

    Subtle meaning
    1) A FSH – example all dir’s under ‘/’ on a single partition.
    2) Different (logically grouped or part of entire hierarchy)dir’s under same partition ,different partition’s or on different type-of-filesystem(ext2[3],reiser etc).

    Anyways, keep up the good work.

  • karan Dec 19, 2008 @ 8:25


    I need some clarification.

    I am very clear that hard links points to same inode number.
    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
    If i am trying to create hard link for /tmp file system.
    For example:
    $ cd /home/karan
    $ touch sfile
    $ ln sfile hfile
    $ ls – ali
    4489496 -rw-r–r– 3 karan karan 0 2008-12-19 13:41 hfile
    4489496 -rw-r–r– 3 karan karan 0 2008-12-19 13:41 sfile

    very clear till this part.

    Do you meant to say that we cannot create hard links like the below?

    $ ln sfile /tmp/hfile

    If i misunderstood,please do clear me.


  • ruggo Dec 22, 2008 @ 23:28


    If the /tmp directory is on the same partition as where ‘sfile’ is, then you can hard link it. You can’t hard link across different partitions/disks. They’re different file systems, therefore the inodes differ on each partition.

  • Nanda Jun 18, 2009 @ 18:28

    Otherwise to say, the inode number will not and can not be unique across filesystems / servers / partitions.

    Hope this helps.

  • Mehdi (ATI/AMD Drivers) Aug 12, 2009 @ 14:47

    I was just wondering how I could make a link to a drive?
    When I do
    root@Ubuntu9:media > ln -s disk disk
    it returns an error saying /media/disk already exists!

    I know it exists I just want to make a link to it (shortcut),
    I know it seems dumb/redundant to make a same name link in the same folder but I was trying to figure out why this disk does not mount?and thought it may help because the cdrom and other disks mount OK and they all have links in the /media!
    when I do mount disk it returns the usual fstab nonsense. It (disk) ONLY come up when I use the GUI and go in My Computer, then it appears in the /media directory?
    So I thought it has something to do with making a link?

  • Babu Satasiya Aug 13, 2009 @ 5:13

    In general we create softlink for sortcut, If you already have file or folder name on current directory, why do you want same name softlink, it does not make sense to have duplicate softlink or even hardlink on same folder or in otherwords, directory maintains filenames and it requires uniq names you can not have duplicate names for given file in same folder.

    if you are planing to create softlink from different partition or folder, it should not cause any problem.

    Look at following example, I am creating data.txt to data.txt it gives error but when I tried data.txt to data1.txt, it works fine.
    ln -s data.txt data.txt
    ln: creating symbolic link `data.txt’: File exists
    ln -s data.txt data1.txt
    ls -la data*.txt
    lrwxrwxrwx 1 root root 8 2009-08-13 00:02 data1.txt -> data.txt
    -rw-r–r– 1 root root 15 2009-08-12 23:53 data.txt

    Hope this helps,
    Babu Satasiya

  • Mehdi (ATI/AMD Drivers) Aug 13, 2009 @ 10:25

    Thanks Babu,
    I used different name and it worked.
    I was testing to see why this 60 Gig hard drive does not mount on ts own while th cdrom0 and floppy0 loaded no problem!?

  • Leave a comment. Jan 24, 2011 @ 4:14

    It’s probably worth mentioning that symbolic links can cross file systems and hard links cannot.

    That’s only because systems programmers are too dumb to come up with hard links that do cross filesystems. Or bidirectional hard links. Or directional hard links.

    [Hard links that cross filesystems would look more and more like symbolic links. Perhaps a more elegant implementation than a pathname-stashed-in-a-file-with-a-particular-bit-in-the-inode-set, but the semantics of a Unix hard link, which make lots of assumptions about the physical layout of the device, clearly don’t apply. When you add in the fact that a cross-volume link might point to a device which isn’t mounted or otherwise isn’t available (a remote filesystem across a network which is down), failure semantics must be thrown in as well.]

    [A counter-example–even one of research quality only–might be a good thing, though.]

    How would a hard link cross file system boundaries without becoming a symbolic link?

    Easy, it’s a chain of hard links. The first link in the chain points to the remote object component and has the name of the link to follow in it. The link in the remote system is either a hard link pointing to the target or it’s another link that points to a remote object component and has … blah blah. And of course, this is bidirectional.

    The trick is that since these links are all in the root>>portals of the systems in question, they’re inaccessible to the casual user even if they “cross” user-space. As a consequence, they can’t be broken by a casual user but must be deleted properly by someone with legitimate permission to do so, or broken by the owner of one of the systems in the chain. IOW, these are NOT symbolic links!


  • sumant Jun 3, 2011 @ 19:34

    I want know about u have create a hardlink that time delete man hardlink file. then u have access that file or not tell me please

  • eric peyser Oct 17, 2011 @ 18:51

    with what Franklin put forth, go over the example again. When spanning multiple FS you may encounter duplicate inodes. On a single physical HD with multiple mount points most FS (that i know of) keep track of the data by drive. the inodes are created in a incremental fashion.

    -Eric Peyser

  • eric peyser Oct 17, 2011 @ 18:55

    I may date myself here —-but –Unix beyond the magic garden– was a great book. It had alot of internals. from FS and the internals to IPC and named/unnamed pipe info. It helped me to understand what was behind the screen. BTW article was great !!!!

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum