ln: creating hard link 问题
来源:互联网 发布:机房网络维护 编辑:程序博客网 时间:2024/06/05 04:59
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 dir1linkln: failed to create hard link `dir1link' => `dir1': Operation not permittedroot@x:~/testdir# unlink dir1unlink: 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
showsl
as the first character of the type/permission field.stat
output showssymbolic 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 ofls -l
shows the number of hardlinks to the inode.
user1@x:~/testdir$ ls -litotal 126865008 drwxrwxr-x 2 user1 user1 4096 Jul 30 00:50 dir16822146 lrwxrwxrwx 1 user1 user1 4 Jul 30 01:44 dir1symlink -> dir16822155 -rw-rw-r-- 2 user1 user1 64 Jul 30 01:44 file16822155 -rw-rw-r-- 2 user1 user1 64 Jul 30 01:44 file1hardlinkuser1@x:~/testdir$ stat * | grep -E '((File)|(Size)|(Device)):' File: `dir1' Size: 4096 Blocks: 8 IO Block: 4096 directoryDevice: 807h/2055d Inode: 6865008 Links: 2 File: `dir1symlink' -> `dir1' Size: 4 Blocks: 0 IO Block: 4096 symbolic linkDevice: 807h/2055d Inode: 6822146 Links: 1 File: `file1' Size: 64 Blocks: 8 IO Block: 4096 regular fileDevice: 807h/2055d Inode: 6822155 Links: 2 File: `file1hardlink' Size: 64 Blocks: 8 IO Block: 4096 regular fileDevice: 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/.linktohomedir
are 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.
chown root.root / home/user1/.profileln / home/user1/.profile / home/user2/.profileln / home/user1/.profile / home/user3/.profile... (For all users)
I do not understand the following lines
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 permittedlinux: / usr / lib / openoffice / share / fonts #
chown root.root / home/user1/.profileln / home/user1/.profile / home/user2/.profileln / home/user1/.profile / home/user3/.profile... (For all users)
> Ln-v-d / usr/X11R6/lib/X11/fonts/TT /
ln one
-D,-F, - directory
- ln: creating hard link 问题
- ln 命令用法 hard link 与 symbolic link 区别 分析
- 【已解决】ln: creating symbolic link XXXXXX : Operation not supported
- ln: creating symbolic link `asm' to `asm-arm':
- 【已解决】ln: creating symbolic link XXXXXX : Operation not supported
- ln: creating symbolic link XXXXXX : Operation not supported
- ln: creating symbolic link XXXXXX : Operation not supported
- ln: creating symbolic link XXXXXX : Operation not supported
- ln: creating symbolic link 'path' Operation not supported 问题解决方法
- 编译内核出现ln: creating symbolic link `include/asm' to `asm-arm': Operation not supported
- 编译内核出现ln: creating symbolic link `include/asm' to `asm-arm': Operation not supported
- 编译Linux内核错误:ln: creating symbolic link `include/asm': Operation not supported
- Hard link, symbolic link
- ln: creating symbolic link XX : Operation not supported(Linux下对windows文件创建软链接失败)
- Hard Link versus Symbolic Link
- Hard link 和 Symbolic link
- ubuntu soft link & hard link
- hard link and symbolic link
- C++读取ini文件的类
- 看懂此文,不再困惑于javascript中的事件绑定、事件冒泡、事件捕获和事件执行顺序
- std::cout彩色输出
- boost实现串口通信(一):小试牛刀
- amr格式转换为MP3格式
- ln: creating hard link 问题
- boost:exception使用实例
- boost:thread使用实例
- boost::asio 使用实例
- libpcap报文解析: ipv4、ipv6(待优化)
- pcap文件格式及文件解析
- 编程网站收集
- Oracle中查看所有表和字段以及表注释.字段注释
- libpcap报文解析: ipv4、ipv6 @ 2014.7.2