在 samba 连接的 NAS 上移动文件

Chr*_*ård 6 samba windows-7 nas

这可能是一个愚蠢的问题,但是当我在我的 NAS 盒 (freeNAS) 上移动文件时,数据是否通过我的 Windows PC 传输?

我复制的时候呢?

我一直害怕清理我的 NAS 盒,因为我不知道文件是否需要几个小时才能移动等等......

Sky*_*eam 7

这取决于源和目标:

相同的源和目标共享:
如果源和目标位于同一个 SMB 共享上,那么您的客户端只需发送命令来移动它。数据本身永远不会传输到您的客户端并再次上传到服务器。这也允许您在几毫秒内移动千兆字节的文件,即使在慢速 VPN 连接上也是如此。

Different source and destination share:
In case the source and destination folders are not on the same SMB share, then even if you move the data it's transferred via your local machine. So the network transfer is around two times the data size (read data, write data, delete data on old location).

Copy:
If you copy data it's always copied via your client. So always the traffic is around double the data size.

So yes, moving is only fast if done on the same share. If you use a NAS with local shell access you might be able to do some move operations faster by logging in on the shell and moving the folders directly on NAS side. For example you want to move files from \\nas\incoming\ to \\nas\archived\ then moving files via Samba/SMB will mean to copy the data via network from one share to the other. Assuming that on the NAS the directory structure looks as follows (example):

/data/
/data/incoming
/data/archived
...
Run Code Online (Sandbox Code Playgroud)

And assuming /data/ is on the same volume (check using mount command) then executing the following will be much faster:

mv "/data/incoming/some-folder" "/data/archived"
Run Code Online (Sandbox Code Playgroud)

This would move all the data almost immediately since the move operation on the file system is just about adding a reference to the some-folder directory in archived and removing the reference from incoming.

警告:如果您在 shell 上移动数据,那么您也会移动它,包括所有权限。因此,您可能需要some-folder在移动后调整其权限以匹配文件archived夹中其他文件的权限。