Java files.move 报错

背景:

需要将文件从NAS挂载的硬盘归档到本地硬盘,报错 Invalid cross-device link

[root@VM_9_13_centos opt]# df -hT
Filesystem                               Type      Size  Used Avail Use% Mounted on
/dev/vda1                                ext3       50G   46G  1.4G  98% /
devtmpfs                                 devtmpfs  3.9G     0  3.9G   0% /dev
tmpfs                                    tmpfs     3.9G   24K  3.9G   1% /dev/shm
tmpfs                                    tmpfs     3.9G  548K  3.9G   1% /run
tmpfs                                    tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
10.41.99.102:/exstorage/ecommerce/remind nfs4       10G  100M  9.9G   1% /opt/ipcis/web/remind
tmpfs                                    tmpfs     783M     0  783M   0% /run/user/1000
tmpfs                                    tmpfs     783M     0  783M   0% /run/user/0
10.41.10.9:/vsftpdata/channel/dat        nfs4       50G  6.7G   41G  15% /opt/epartnerimg
10.41.10.9:/vsftpdata/rhchi/tuixiang/dat nfs4       50G  6.7G   41G  15% /opt/tuixiangimg

在系统上测试mv命令
[root@VM_9_13_centos opt]# mv tuixiangimg/01D2018091007931/ tuixiang_archive/
mv: cannot remove ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/1.2.392.200036.9116.2.6.1.37.2420991567.1536711606.161377’: Permission denied
mv: cannot remove ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/1.2.392.200036.9116.2.6.1.37.2420991567.1536711616.348524’: Permission denied
mv: cannot remove ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/1.2.392.200036.9116.2.6.1.37.2420991567.1536711616.327246’: Permission denied

lsof查看

[root@VM_9_13_centos opt]# lsof |grep tuixiangimg
java       3430                admin   76r      DIR               0,38       4096    2138201 /opt/tuixiangimg (10.41.10.9:/vsftpdata/rhchi/tuixiang/dat)
java       3430                admin   78r      DIR               0,38       4096    2138201 /opt/tuixiangimg (10.41.10.9:/vsftpdata/rhchi/tuixiang/dat)
java       3430                admin  294r      DIR               0,38       4096    2138201 /opt/tuixiangimg (10.41.10.9:/vsftpdata/rhchi/tuixiang/dat)

关闭java进程测试 , 还是mv失败

[root@VM_9_13_centos opt]# mv tuixiangimg/01D2018091007931/ tuixiang_archive/
mv: cannot remove ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/1.2.392.200036.9116.2.6.1.37.2420991567.1536711606.161377’: Permission denied
mv: cannot remove ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/1.2.392.200036.9116.2.6.1.37.2420991567.1536711616.348524’: Permission denied
mv: cannot remove ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/1.2.392.200036.9116.2.6.1.37.2420991567.1536711616.327246’: Permission denied

测试mv单个文件
[root@VM_9_13_centos opt]# mv tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json tuixiang_archive/
mv: cannot remove ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json’: Permission denied

strace 追踪

[root@VM_9_13_centos opt]# strace -fF mv tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json tuixiang_archive/
execve("/usr/bin/mv", ["mv", "tuixiangimg/01D2018091007931/201"..., "tuixiang_archive/"], [/* 25 vars */]) = 0
brk(0)                                  = 0xad0000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd44b788000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=31613, ...}) = 0
mmap(NULL, 31613, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fd44b780000
close(3)                                = 0
open("/lib64/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320i\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=155784, ...}) = 0
mmap(NULL, 2255184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fd44b342000
mprotect(0x7fd44b366000, 2093056, PROT_NONE) = 0
mmap(0x7fd44b565000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x23000) = 0x7fd44b565000
mmap(0x7fd44b567000, 6480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fd44b567000
close(3)                                = 0
open("/lib64/libacl.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200\37\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=37056, ...}) = 0
mmap(NULL, 2130560, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fd44b139000
mprotect(0x7fd44b140000, 2097152, PROT_NONE) = 0
mmap(0x7fd44b340000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x7000) = 0x7fd44b340000
close(3)                                = 0
open("/lib64/libattr.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\23\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19888, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd44b77f000
mmap(NULL, 2113904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fd44af34000
mprotect(0x7fd44af38000, 2093056, PROT_NONE) = 0
mmap(0x7fd44b137000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7fd44b137000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2118128, ...}) = 0
mmap(NULL, 3932672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fd44ab73000
mprotect(0x7fd44ad2a000, 2093056, PROT_NONE) = 0
mmap(0x7fd44af29000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7fd44af29000
mmap(0x7fd44af2f000, 16896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fd44af2f000
close(3)                                = 0
open("/lib64/libpcre.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\360\25\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=398264, ...}) = 0
mmap(NULL, 2490888, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fd44a912000
mprotect(0x7fd44a972000, 2093056, PROT_NONE) = 0
mmap(0x7fd44ab71000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5f000) = 0x7fd44ab71000
close(3)                                = 0
open("/lib64/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\16\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=19776, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd44b77e000
mmap(NULL, 2109744, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fd44a70e000
mprotect(0x7fd44a710000, 2097152, PROT_NONE) = 0
mmap(0x7fd44a910000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fd44a910000
close(3)                                = 0
open("/lib64/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240l\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=143944, ...}) = 0
mmap(NULL, 2208864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fd44a4f2000
mprotect(0x7fd44a509000, 2093056, PROT_NONE) = 0
mmap(0x7fd44a708000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7fd44a708000
mmap(0x7fd44a70a000, 13408, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fd44a70a000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd44b77d000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd44b77b000
arch_prctl(ARCH_SET_FS, 0x7fd44b77b800) = 0
mprotect(0x7fd44af29000, 16384, PROT_READ) = 0
mprotect(0x7fd44a708000, 4096, PROT_READ) = 0
mprotect(0x7fd44a910000, 4096, PROT_READ) = 0
mprotect(0x7fd44ab71000, 4096, PROT_READ) = 0
mprotect(0x7fd44b137000, 4096, PROT_READ) = 0
mprotect(0x7fd44b340000, 4096, PROT_READ) = 0
mprotect(0x7fd44b565000, 4096, PROT_READ) = 0
mprotect(0x61d000, 4096, PROT_READ)     = 0
mprotect(0x7fd44b789000, 4096, PROT_READ) = 0
munmap(0x7fd44b780000, 31613)           = 0
set_tid_address(0x7fd44b77bad0)         = 9494
set_robust_list(0x7fd44b77bae0, 24)     = 0
rt_sigaction(SIGRTMIN, {0x7fd44a4f8780, [], SA_RESTORER|SA_SIGINFO, 0x7fd44a501370}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7fd44a4f8810, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7fd44a501370}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
statfs("/sys/fs/selinux", 0x7fffc0b09c50) = -1 ENOENT (No such file or directory)
statfs("/selinux", 0x7fffc0b09c50)      = -1 ENOENT (No such file or directory)
brk(0)                                  = 0xad0000
brk(0xaf1000)                           = 0xaf1000
open("/proc/filesystems", O_RDONLY)     = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd44b787000
read(3, "nodev\tsysfs\nnodev\trootfs\nnodev\tr"..., 1024) = 336
stat("/etc/sysconfig/64bit_strstr_via_64bit_strstr_sse2_unaligned", 0x7fffc0b09b30) = -1 ENOENT (No such file or directory)
read(3, "", 1024)                       = 0
close(3)                                = 0
munmap(0x7fd44b787000, 4096)            = 0
access("/etc/selinux/config", F_OK)     = 0
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=106070960, ...}) = 0
mmap(NULL, 106070960, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fd443fc9000
close(3)                                = 0
geteuid()                               = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
stat("tuixiang_archive/", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json", {st_mode=S_IFREG|0644, st_size=2280, ...}) = 0
lstat("tuixiang_archive/21203873.json", {st_mode=S_IFREG|0644, st_size=2280, ...}) = 0
geteuid()                               = 0
rename("tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json", "tuixiang_archive/21203873.json") = -1 EXDEV (Invalid cross-device link)
unlink("tuixiang_archive/21203873.json") = 0
open("tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json", O_RDONLY|O_NOFOLLOW) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2280, ...}) = 0
open("tuixiang_archive/21203873.json", O_WRONLY|O_CREAT|O_EXCL, 0600) = 4
fstat(4, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd44b759000
read(3, "\377\376{\0\r\0\n\0 \0 \0\"\0u\0r\0l\0\"\0:\0 \0\"\0h\0t\0"..., 131072) = 2280
write(4, "\377\376{\0\r\0\n\0 \0 \0\"\0u\0r\0l\0\"\0:\0 \0\"\0h\0t\0"..., 2280) = 2280
read(3, "", 131072)                     = 0
utimensat(4, NULL, {{1574259798, 0}, {1574259798, 0}}, 0) = 0
fchown(4, 1000, 1000)                   = 0
flistxattr(3, NULL, 0)                  = 16
flistxattr(3, "system.nfs4_acl\0", 16)  = 16
open("/etc/xattr.conf", O_RDONLY)       = -1 ENOENT (No such file or directory)
fgetxattr(3, "system.nfs4_acl", 0x0, 0) = 80
fgetxattr(3, "system.nfs4_acl", "\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x16\x01\x87\x00\x00\x00\x06OWNER@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x81\x00\x00\x00\x06GROUP@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x81\x00\x00\x00\x09EVERYONE@\x00\x00", 80) = 80
fsetxattr(4, "system.nfs4_acl", "\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x16\x01\x87\x00\x00\x00\x06OWNER@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x81\x00\x00\x00\x06GROUP@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x81\x00\x00\x00\x09EVERYONE@\x00\x00", 80, 0) = -1 EOPNOTSUPP (Operation not supported)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=2502, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd44b787000
read(5, "# Locale name alias data base.\n#"..., 4096) = 2502
read(5, "", 4096)                       = 0
close(5)                                = 0
munmap(0x7fd44b787000, 4096)            = 0
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
fgetxattr(3, "system.posix_acl_access", 0x7fffc0b094c0, 132) = -1 EOPNOTSUPP (Operation not supported)
fsetxattr(4, "system.posix_acl_access", "\x02\x00\x00\x00\x01\x00\x06\x00\xff\xff\xff\xff\x04\x00\x04\x00\xff\xff\xff\xff \x00\x04\x00\xff\xff\xff\xff", 28, 0) = 0
close(4)                                = 0
close(3)                                = 0
munmap(0x7fd44b759000, 139264)          = 0
lstat("/", {st_mode=S_IFDIR|0555, st_size=4096, ...}) = 0
newfstatat(AT_FDCWD, "tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json", {st_mode=S_IFREG|0644, st_size=2280, ...}, AT_SYMLINK_NOFOLLOW) = 0
unlinkat(AT_FDCWD, "tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json", 0) = -1 EACCES (Permission denied)
write(2, "mv: ", 4mv: )                     = 4
write(2, "cannot remove \342\200\230tuixiangimg/01D"..., 129cannot remove ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json’) = 129
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Permission denied", 19: Permission denied)     = 19
write(2, "\n", 1
)                       = 1
lseek(0, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
close(0)                                = 0
close(1)                                = 0
close(2)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++
[root@VM_9_13_centos opt]# 
试试删除
[root@VM_9_13_centos opt]# rm tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json 
rm: remove regular file ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json’? y
rm: cannot remove ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json’: Permission denied

strace 追踪删除

[root@VM_9_13_centos opt]# strace -fF rm tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json 
execve("/usr/bin/rm", ["rm", "tuixiangimg/01D2018091007931/201"...], [/* 25 vars */]) = 0
brk(0)                                  = 0x1d1f000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5a7a5e5000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=31613, ...}) = 0
mmap(NULL, 31613, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5a7a5dd000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2118128, ...}) = 0
mmap(NULL, 3932672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5a7a005000
mprotect(0x7f5a7a1bc000, 2093056, PROT_NONE) = 0
mmap(0x7f5a7a3bb000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7f5a7a3bb000
mmap(0x7f5a7a3c1000, 16896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5a7a3c1000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5a7a5dc000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5a7a5da000
arch_prctl(ARCH_SET_FS, 0x7f5a7a5da740) = 0
mprotect(0x7f5a7a3bb000, 16384, PROT_READ) = 0
mprotect(0x60d000, 4096, PROT_READ)     = 0
mprotect(0x7f5a7a5e6000, 4096, PROT_READ) = 0
munmap(0x7f5a7a5dd000, 31613)           = 0
brk(0)                                  = 0x1d1f000
brk(0x1d40000)                          = 0x1d40000
brk(0)                                  = 0x1d40000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=106070960, ...}) = 0
mmap(NULL, 106070960, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5a73adc000
close(3)                                = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
newfstatat(AT_FDCWD, "tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json", {st_mode=S_IFREG|0644, st_size=2280, ...}, AT_SYMLINK_NOFOLLOW) = 0
geteuid()                               = 0
unlinkat(AT_FDCWD, "tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json", 0) = -1 EACCES (Permission denied)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2502, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5a7a5e4000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2502
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f5a7a5e4000, 4096)            = 0
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
write(2, "rm: ", 4rm: )                     = 4
write(2, "cannot remove \342\200\230tuixiangimg/01D"..., 129cannot remove ‘tuixiangimg/01D2018091007931/20180912/1.2.392.200036.9116.2.6.1.37.2420991567.1536711580.585775/21203873.json’) = 129
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Permission denied", 19: Permission denied)     = 19
write(2, "\n", 1
)                       = 1
lseek(0, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
close(0)                                = 0
close(1)                                = 0
close(2)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++
[root@VM_9_13_centos opt]# 

在挂载目录下创建文件测试,失败
[root@VM_9_13_centos tuixiangimg]# touch 1
touch: cannot touch ‘1’: Permission denied

strace 追踪

[root@VM_9_13_centos tuixiangimg]# strace -fF touch 1
execve("/usr/bin/touch", ["touch", "1"], [/* 25 vars */]) = 0
brk(0)                                  = 0x253d000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe512db9000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=31613, ...}) = 0
mmap(NULL, 31613, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe512db1000
close(3)                                = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0@\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2118128, ...}) = 0
mmap(NULL, 3932672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe5127d9000
mprotect(0x7fe512990000, 2093056, PROT_NONE) = 0
mmap(0x7fe512b8f000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1b6000) = 0x7fe512b8f000
mmap(0x7fe512b95000, 16896, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe512b95000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe512db0000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe512dae000
arch_prctl(ARCH_SET_FS, 0x7fe512dae740) = 0
mprotect(0x7fe512b8f000, 16384, PROT_READ) = 0
mprotect(0x60d000, 4096, PROT_READ)     = 0
mprotect(0x7fe512dba000, 4096, PROT_READ) = 0
munmap(0x7fe512db1000, 31613)           = 0
brk(0)                                  = 0x253d000
brk(0x255e000)                          = 0x255e000
brk(0)                                  = 0x255e000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=106070960, ...}) = 0
mmap(NULL, 106070960, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe50c2b0000
close(3)                                = 0
open("1", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = -1 EACCES (Permission denied)
utimensat(AT_FDCWD, "1", NULL, 0)       = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2502, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe512db8000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2502
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7fe512db8000, 4096)            = 0
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
write(2, "touch: ", 7touch: )                  = 7
write(2, "cannot touch \342\200\2301\342\200\231", 20cannot touch ‘1’) = 20
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Permission denied", 19: Permission denied)     = 19
write(2, "\n", 1
)                       = 1
close(1)                                = 0
close(2)                                = 0
exit_group(1)                           = ?
+++ exited with 1 +++
[root@VM_9_13_centos tuixiangimg]# 


上面的排错过程,确定 root 也没有办法在nas存储(nfs挂载)上创建文件
排查思路转到nfs
查看nfs模式,配置

[root@VM_10_9_centos ~]# cat /etc/exports
/vsftpdata *(rw,all_squash,anonuid=1001,anongid=1001)

[root@VM_10_9_centos ~]# id vftpuser
uid=1000(vftpuser) gid=1000(vftpuser) groups=1000(vftpuser)

某次设置NFS账户id同步的时候,变更vftpuser 的 uid和gid了。那就写不进了嘛 。


修复

修改nfs配置 ,然后重新发布

[root@VM_10_9_centos ~]# cat /etc/exports
/vsftpdata *(rw,all_squash,anonuid=1000,anongid=1000)

[root@VM_10_9_centos ~]# exportfs -ra

测试在故障设备上创建文件,测试成功

[root@VM_9_13_centos tuixiangimg]# touch 1
[root@VM_9_13_centos tuixiangimg]# ls
01D2018091007931  1

测试归档文件夹

[root@VM_9_13_centos opt]# mv tuixiangimg/01D2018091007931/ tuixiang_archive/
[root@VM_9_13_centos opt]# 

归档成功,美滋滋

让同事测试JAVA归档


微信图片_20191122110034.png

还是同一个报错。


换个思路

baidu + google
https://stackoverflow.com/questions/24209886/invalid-cross-device-link-error-with-boost-filesystem

有如下解释:
If renaming a file (ultimately through the rename() library call, whether it's wrapped up in boost:: or anything else) fails because the source and destination are on different file systems, the only option is to then copy the file and delete the original after verifying that the copy was complete and successful. This is what /bin/mv does - it first tries a rename(), and if the error code returned by it's failure indicates a cross-device link situation, it falls back to a copy and remove scenario.
翻译下:
如果重命名一个文件 (根本上还是调用 rename() library ,不管是用boost:: 还是其他) 失败,是因为源文件和目的文件位于不同的文件系统上,仅有的选项是拷贝文件然后在确认拷贝完成后删除源文件。这也是/bin/mv所采用的- 它首先尝试rename(),如果失败返回“cross-device link situation”的代码,就会回到copy 和 remove 的方案。


容我有空看下/bin/mv 怎么写的。

info coreutils 'mv invocation'

有如下描述
'mv' can move any type of file from one file system to another.
Prior to version '4.0' of the fileutils, 'mv' could move only regular
files between file systems. For example, now 'mv' can move an entire
directory hierarchy including special device files from one partition to
another.

It first uses some of the same code that's used by 'cp -a' tocopy the requested directories and files, then (assuming the copysucceeded) it removes the originals.

If the copy fails, then the part
that was copied to the destination partition is removed. If you were to
copy three directories from one partition to another and the copy of the
first directory succeeded, but the second didn't, the first would be
left on the destination partition and the second and third would be left
on the original partition.

'mv' always tries to copy extended attributes (xattr), which may
include SELinux context, ACLs or Capabilities. Upon failure all but
'Operation not supported' warnings are output.

If a destination file exists but is normally unwritable, standard
input is a terminal, and the '-f' or '--force' option is not given, 'mv'
prompts the user for whether to replace the file. (You might own the
file, or have write permission on its directory.) If the response is
not affirmative, the file is skipped.

Warning: Avoid specifying a source name with a trailing slash, when
it might be a symlink to a directory. Otherwise, 'mv' may do something
very surprising, since its behavior depends on the underlying rename
system call. On a system with a modern Linux-based kernel, it fails
with 'errno=ENOTDIR'. However, on other systems (at least FreeBSD 6.1
and Solaris 10) it silently renames not the symlink but rather the
directory referenced by the symlink. *Note Trailing slashes::.

java不能解决跨设备的mv,必须使用copy + remove方案。

你可能感兴趣的:(Java files.move 报错)