Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am curious that hard link cannot cross the boundary of file system. But where exactly is the boundary? I know hard disk and flash disk are two file systems; /home and /var are two file systems. But how about /home/a and /home/b? I am quite confused.

share|improve this question

migrated from stackoverflow.com Apr 23 '13 at 13:14

This question came from our site for professional and enthusiast programmers.

1 Answer 1

In this case, the boundary is the "device". If you do df -h /home, it will print something like this:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb1       917G  353G  519G  41% /home

Note that the "filesystem" isn't /home, it's /dev/sdb1, i.e. one partition of the hard disk sdb. /home is just a "mount point".

When you look at this device node, you get something like this:

brw-rw---- 1 root disk 8,  17 Apr 23 09:33 /dev/sdb1

The b means it's a block device. The two numbers between disk and the date (8, 17) are the major and minor number. They are what you can call a unique device ID.

A hard link just contains the name of the entry and the number of an inode. Since there is no place to store the unique device ID, the hard link cannot point to a different device There are technical reasons for this as well, like with USB disks, the same "unique device ID" is only unique until you restart. So even if you could create hard links between file systems, there would be no way to be sure they were still valid after a reboot (among other reasons).

Note that the partition on your hard disk is the "file system", not the place where it is "mounted". That is, you can mount /dev/sdb1 on /mnt, too. That doesn't change what the file system is, it just changes the path that you must use to locate data on the file system (again, even in the language, the file system isn't the path).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.