Solved: ln: failed to create hard link: Operation not permitted in Linux.
Today in this post, we will see a common error message and its solution.
Lets see the error message and its solution.
I. Errors
TRKINS: Installing package JOO_e version 22.09-s001 [NOTE - DV::Package::Tarkit] ln: failed to create hard link '/dv/project/main/ngelproject/dep/packages/JOO_e22.09-s001lnx86.t.Z' => '/dv/project/main/ngelproject/exchange/ACTIVE/JOO_e22.09-s001lnx86.t.Z': Operation not permitted TRKCP: Could not copy /dv/project/main/ngelproject/exchange/ACTIVE/JOO_e22.09-s001lnx86.t.Z to /dv/project/main/ngelproject/dep/packages [ERROR - DV::Package::Tarkit] TRKINS: Installing package sn_common version 22.09-s001 [NOTE - DV::Package::Tarkit] ln: failed to create hard link '/dv/project/main/ngelproject/dep/packages/sn_common22.09-s001lnx86.t.Z' => '/dv/project/main/ngelproject/exchange/ACTIVE/sn_common22.09-s001lnx86.t.Z': Operation not permitted TRKCP: Could not copy /dv/project/main/ngelproject/exchange/ACTIVE/sn_common22.09-s001lnx86.t.Z to /dv/project/main/ngelproject/dep/packages [ERROR - DV::Package::Tarkit] TRKINS: Installing package sn_test_only_Int version 22.09-s001 [NOTE - DV::Package::Tarkit] ln: failed to create hard link '/dv/project/main/ngelproject/dep/packages/sn_test_only_Int22.09-s001lnx86.t.Z' => '/dv/project/main/ngelproject/exchange/ACTIVE/sn_test_only_Int22.09-s001lnx86.t.Z': Operation not permitted TRKCP: Could not copy /dv/project/main/ngelproject/exchange/ACTIVE/sn_test_only_Int22.09-s001lnx86.t.Z to /dv/project/main/ngelproject/dep/packages [ERROR - DV::Package::Tarkit]
II. Analysis and Solution
a. Check out the value of protected hard links.
[root@ngelinux001 share]# cat /proc/sys/fs/protected_hardlinks 1
Here 1 means the process UID which is creating the link must match the owner UID of the target file.
b. Lets make it 0 to resolve this.
[root@ngelinux001 share]# vi /etc/sysctl.conf [root@ngelinux001 share]# sysctl -p kernel.panic = 300 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 fs.inotify.max_user_watches = 131072 fs.inotify.max_user_instances = 8192 fs.protected_hardlinks = 0 [root@ngelinux001 ~]# cat /proc/sys/fs/protected_hardlinks 0 [root@ngelinux001 ~]# cat /etc/sysctl.conf | grep -i hardlink fs.protected_hardlinks = 0
Now since the protected hard link parameter is off, the UID of target file will not be matched with process owner ID.