其实很简单:

chattr -R -i xxxxx           #xxxxx为你需要修改的文件,这样就可以了。。。

下面全不是重点,扯淡。。。。

ln: creating hard link `xxx' => `/opt/xx': Operation not permitted

摘自http://www.windowslinuxosx.com/q/answers-how-do-i-remove-a-possible-hard-link-directory-to-root-625072.html

Solution

The files and directories in the .linktorootdir directory are copied from the root directory. You can simply delete them using for example rm -rf /volume1/usbcopy/USBCopy_1303012145/.linktohomedir.

The explanation is below.

Hardlinks of directories

Hardlinks to directories are theoretically possible but because of multiple reasons they are disabled in many systems including Linux. This also means that you will not be able to remove a hardlink to directory as the unlink() syscall will not allow it.

Demonstration

root@x:~/testdir# ln -F dir1 dir1link
ln: failed to create hard link `dir1link' => `dir1': Operation not permitted
root@x:~/testdir# unlink dir1
unlink: cannot unlink `dir1': Is a directory

The shown denial is hardwired in the Linux kernel (fs/namei.c). Here are the results of syscalls:

linkat(AT_FDCWD, "dir1", AT_FDCWD, "dir1link", 0) = -1 EPERM (Operation not permitted)
unlink("dir1") = -1 EISDIR (Is a directory)

Recognizing the two types of links

  • softlink - ls -l shows l as the first character of the type/permission field. stat output shows symbolic link.
  • hardlink - Hardlinks are mutually indistinguishable. Both the original file and newly created hardlink look exactly the same except the path/filename. Hardlinks cannot point from one filesystem to another. ls -i shows the same inode number for all files hardlinked to the same data (represented by inode). The second column of ls -l shows the number of hardlinks to the inode.
user1@x:~/testdir$ ls -li
total 12
6865008 drwxrwxr-x 2 user1 user1 4096 Jul 30 00:50 dir1
6822146 lrwxrwxrwx 1 user1 user1 4 Jul 30 01:44 dir1symlink -> dir1
6822155 -rw-rw-r-- 2 user1 user1 64 Jul 30 01:44 file1
6822155 -rw-rw-r-- 2 user1 user1 64 Jul 30 01:44 file1hardlink user1@x:~/testdir$ stat * | grep -E '((File)|(Size)|(Device)):'
File: `dir1'
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 807h/2055d Inode: 6865008 Links: 2
File: `dir1symlink' -> `dir1'
Size: 4 Blocks: 0 IO Block: 4096 symbolic link
Device: 807h/2055d Inode: 6822146 Links: 1
File: `file1'
Size: 64 Blocks: 8 IO Block: 4096 regular file
Device: 807h/2055d Inode: 6822155 Links: 2
File: `file1hardlink'
Size: 64 Blocks: 8 IO Block: 4096 regular file
Device: 807h/2055d Inode: 6822155 Links: 2

Origin of .linktorootdir

In the .dfmdesk directory DFM creates some links during the first start. These links will be shown as icons on the desktop. Between the links there will be two links to directories:.linktorootdir as a symlink to the root directory of the system DFM is running on and also.linktohomedir. See the DFM documentation and the DFM source.

In your case the directories / and /volume1/usbcopy/USBCopy_1303012145/.linktohomedirare on different filesystems (/dev/root and /dev/vg1000/lv) so they cannot be hardlinks to the same inode. (Hardlinks can point just in the scope of a single filesystem.)

We can guess how the problem you describe emerged. Most probably the backup to NTFS was able to keep the symlink as NTFS has this capability. Later when you copied the backup from the USB drive the copying tool did not handle symlinks as expected. Instead of copying just the symbolic link itself, the tool followed the symbolic links on the source drive and copied the content of them (root directory in the case of .linktorootdir). The similar problem is describe also in the Synology forum: USBCopy cought in infinity loop while copying HDD.

The solution is described at the beginning.

A hard link is a directory entry that references the same inode as another directory entry (only working in the same file system). One should therefore avoid very sparingly and use only with good reason. If possible you should SymLinks favor, because hard links are difficult to understand something as symlinks, and are also not all programs be supported and you may want / would imagine it. Absolutely common for the uninitiated copy (not!) way, is something like:

Code:
chown root.root / home/user1/.profile
ln / home/user1/.profile / home/user2/.profile
ln / home/user1/.profile / home/user3/.profile
... (For all users)

This is all well all user profiles a par "(what the user personally, but not good and perhaps not even find the meaning of. profile equivalent), but an outsiders' Admin occurs as rapidly in a faux pas when he says, local what to change, its change in a magical way (via hard link) globally to all user s impact. And it is particularly bad if the setting happens to a terminal and then you see nothing more )

Hello,
I do not understand the following lines

Code:
linux: / usr / lib / openoffice / share / fonts # ln-v-d / usr/X11R6/lib/X11/fonts/TT /
create hard link `. / dd 'to` / usr/X11R6/lib/X11/fonts/TT'
Ln: creating hard link `. / Dd 'to `/ usr/X11R6/lib/X11/fonts/TT ': Operation not permitted
linux: / usr / lib / openoffice / share / fonts #

How can i make a hard link to that directory? Also what exact is the work of a hard link in linux. Thank you for your help.

  #2  
 20-08-2010
Member
 
Join Date: Mar 2010
Posts: 162
 
Re: How to create Hard Link in Linux

A hard link is a directory entry that references the same inode as another directory entry (only working in the same file system). One should therefore avoid very sparingly and use only with good reason. If possible you should SymLinks favor, because hard links are difficult to understand something as symlinks, and are also not all programs be supported and you may want / would imagine it. Absolutely common for the uninitiated copy (not!) way, is something like:

Code:
chown root.root / home/user1/.profile
ln / home/user1/.profile / home/user2/.profile
ln / home/user1/.profile / home/user3/.profile
... (For all users)

This is all well all user profiles a par "(what the user personally, but not good and perhaps not even find the meaning of. profile equivalent), but an outsiders' Admin occurs as rapidly in a faux pas when he says, local what to change, its change in a magical way (via hard link) globally to all user s impact. And it is particularly bad if the setting happens to a terminal and then you see nothing more )

Re: How to create Hard Link in Linux

See this

Code:
> Ln-v-d / usr/X11R6/lib/X11/fonts/TT /

And

Code:
ln one

ln [OPTION] ... OBJECTIVE [command name]

Code:
-D,-F, - directory

Directories to link hard. (Only super-user)

ln: creating hard link 问题的更多相关文章

  1. ln: creating symbolic link XXXXXX : Operation not supported

    ln: creating symbolic link XXXXXX : Operation not supported 转自:https://blog.csdn.net/z444_579/articl ...

  2. Ubuntu18.10 编译libevent出现错误: creating symbolic link XXXXXX : Operation not supported

    今天在VirtualBox虚拟机下的Ubuntu18.10编译libevent源代码时,按照github中使用cmake方式: $ mkdir build && cd build $ ...

  3. Linux上ln命令详细说明及软链接和硬链接的区别

    硬链接(hard link) UNIX文件系统提供了一种将不同文件链接至同一个文件的机制,我们称这种机制为链接.它可以使得单个程序对同一文件使用不同的名字.这样的好处是文件系 统只存在一个文件的副本, ...

  4. linux命令详解——ln

    ln是linux中又一个非常重要命令,它的功能是为某一个文件在另外一个位置建立一个同不的链接,这个命令最常用的参数是-s,具体用法是:ln -s 源文件 目标文件. 当我们需要在不同的目录,用到相同的 ...

  5. Red Hat5.5 install Generic mysql-5.7.10

    1.确认以下依赖包已安装 [ncurses ncurses-devel openssl-devel bison autoconf automake bison gcc m4 libtool make ...

  6. Linux查看设置系统时区

    关于时区的概念,其实初中地理课已经涉及,很多人都多少了解一些,可能只是细节搞不太清楚.为什么会将地球分为不同时区呢?因为地球总是自西向东自转,东边总比西边先看到太阳,东边的时间也总比西边的早.东边时刻 ...

  7. Mac mySql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)的解决办法

    我的环境:Mac 10.11.6 ,mysql  5.7.14  . mac mySql 报错ERROR 2002 (HY000): Can't connect to local MySQL serv ...

  8. U-Boot移植

    基于天翔的老师的课程, 他的博客在这儿: http://blog.csdn.net/johnmcu/article/details/6561311 注明不能转载, 就重新写一下吧: 1. 安装韦东山的 ...

  9. Linux 系统时间查看 及 时区修改(自动同步时间)

    1:使用date命令查看时区 [root@db-server ~]# date -R   Sun, 11 Jan 2015 07:10:28 -0800   [root@db-server ~]#   ...

随机推荐

  1. C#3

    定义常量:1.静态常量 const(定义时必须初始化)  ...常量都不可以改变 2.动态常量 readonly(定义时不必初始化) \\要在Main方法前面 用法:const double PI = ...

  2. ALITUM DESIGNER 多PIN脚IC元件封装的制作

    多IC芯片的管教众多,一个一个的添加引脚效率较低,网上有好的方法,现总结如下 1 在元件库.schlib中新建元件,画出框图和添加第一个PIN脚 2利用smart paste快速放置众多PIN脚(具体 ...

  3. 金蝶BOS

    1, 金蝶BOS 金蝶BOS是一个开放的集成与应用平台,是金蝶企业管理软件解决方案.合作伙伴解决方案以及客户定制应用的技术平台.能够为企业灵活而迅速的设计.构建.实施和执行一套随需应变的企业管理软件系 ...

  4. channelartlist标签调用实例

    channelartlist标签,大家都知道在DedeCMS的系统中,我们可以用这个标签进行循环子栏目及其栏目的文档数据,这也是DedeCMS系统中,唯一一个支持标签嵌套的调用标签,以DedeV5.6 ...

  5. 日期选择控件-laydate

    laydate控件非常简单易用,只需要调用一个个函数就可以轻松实现日期时间选择. <%@ page language="java" import="java.uti ...

  6. mybatis模板

    因为这里是说mybatis的,所以呢 servlet就不做多说了,代码也不在这里贴出来了. log4j.properties log4j.rootLogger=DEBUG,Console log4j. ...

  7. LayoutInflater的实例化

    获得 LayoutInflater 实例的三种方式 1. LayoutInflater inflater = getLayoutInflater();  //调用Activity的getLayoutI ...

  8. 阿里RDS备份恢复

    未使用root用户操作: 数据库版本要一致 数据目录:/data/mysqlbak/ 先按阿里给的步骤操作,最后出现一步出现,无法找到back_xxx.conf,但该文件已经存在.解决方法: sudo ...

  9. Oracle索引HINT的使用

    存储在数据库中数据的分布情况开发人员或管理员比Oracle优化器更加的清楚,在优化器不能作出最有查询路径选择的情况下,使用HINT(提示)人为的固定查询路径,一定程度能生成更优的执行计划.       ...

  10. How to Modify Public Network Information including VIP in Oracle Clusterware (文档 ID 276434.1)

    APPLIES TO: Oracle Database - Enterprise Edition - Version 11.2.0.3 to 12.1.0.2 [Release 11.2 to 12. ...