Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have /home/myuser/Desktop/rc/.netrc file that i want hardlink to /root, ie home directory of root user. When i do:

ln /home/user/Destkop/rc/.netrc /root

it gives the following error:

ln: creating hard link /root/.netrc' =>.netrc': Invalid cross-device link

but it works when i hardlink the file to myuser's home, ie to /home/myuser.

So, what's the problem, why it says invalid cross-devices when there is only one file system here?

PS. I am using RHEL6

share|improve this question
btw my .netrc permissions is 600, as it should be – Elvin Aslanov Jun 12 '13 at 9:48
Are you sure the two directories are on the same filesystem? Run mount | column -t and take a look. Or, run mountpoint -d /, mountpoint -d /home, mountpoint -d user, and mountpoint -d /root. You should get ... is not a mountpoint for the last three. – Evan Teitelman Jun 12 '13 at 10:22
Please don't cross post on multiple StackExchange sites. – Evan Teitelman Jun 12 '13 at 10:26
@EvanTeitelman The real look is not mount | column -t but column -t < /proc/mounts. – Hauke Laging Jun 12 '13 at 12:11
@HaukeLaging: You're right. /proc/mounts is more likely to show all of the mounts on a system than /etc/mtab, which is where mount pulls its information from. Though, it is worth noting that on many modern systems, /etc/mtab and /proc/mounts are both linked to /proc/self/mounts. – Evan Teitelman Jun 12 '13 at 19:57

It seem to me the BEST way is NOT to use a HARD link but to use a symbolic link instead. You'll find it to be far less of a hassle and things work just fine. Hard link have some interesting problems if you are not aware of them.

See man ln and checkout the -s option!

Please in general use symbolic links instead of HARD links.

share|improve this answer
While it might solve the problem, it doesn't really explain why this is happening. – Bex Aug 18 '15 at 10:22

it's most likely that your /home directory isn't on the same partition as the /root directory.

You can easily check this with cat /etc/fstab hardlinks cannot be created between different partitions, only symlinks can.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.