5

I have one machine that exports two directories, each on one physical hard drive.

When files are moved between these two shares, does the data transit on the network entirely? If so, is there a way to have the transfer behave more like a mv on the remote machine ?

alecail
  • 201
  • 3
  • 7
  • When files are moved *how*? – MDMarra Oct 21 '13 at 18:00
  • @MDMarra Using a mv command on the machine that mounts these shares, or dragging the files in a graphical shell, like Finder on OS X. – alecail Oct 21 '13 at 18:03
  • The fact that this is two separate exports, makes me suspect that it is going to moved via your system. If it was a single export, I suspect it would be done by RPC. Not entirely sure about this though. – Zoredache Oct 21 '13 at 18:19
  • why not take a pcap or use netstat to look at traffic/connections to see what, if anything, is going out over the wire? Or use strace to see what calls are being made with the mv? – MaQleod Oct 21 '13 at 20:23

3 Answers3

8

NFS server-side copy is a proposed extension for NFSv4.2.
While initial support has made it into the Linux 3.11 kernel, you could be waiting a while for this.

84104
  • 12,905
  • 6
  • 45
  • 76
  • server-side-copy implemented in upstream linux kernel – kofemann Oct 22 '13 at 05:50
  • If you want to test this, try `cp --sparse=never` to force using `copy_file_range()` which is the way NFS clients implement this. – Braiam Dec 29 '22 at 22:19
  • to update the decade old Q&A - server-side-copy landed in kernel 4.9 for nfsd. Not scope of question: since 5.6 it's also possible to do *intra*-server-side-copy and let two remote nfs servers figure it out - git commits linked at https://serverfault.com/a/788682/429728 – wbob Apr 11 '23 at 00:09
3

If you initiate the transfer on a client host, then yes, all data travels the wire. IF you initiate on the nfs server, whether you use the local directory paths or the mount points, it does not hit the wire. You can see this for yourself running tcpdump, in both cases. netstat may help you a little to see this, but tcpdump will show you the actual quantity of traffic.

The reason this is, is because mv does not known anything about NFS, it uses system calls on your local kernel, and the kernel doesn't know that mount points A and B are both exported from the same server. It treats the data the same.

The only way you can get the behavior you want is by issuing a shell command on the remote server to do the transfer there.

Michael Martinez
  • 2,645
  • 3
  • 24
  • 35
1

It depends on what system and what application you're doing the move from.

If you're doing it via the machine where these shares are at, it'll transfer locally through the OS. Example: ssh to server and using the MV command or opening a File Browser and transferring files from one File Browser to the next (so long as both File Browsers are opened to resources on same server).

The reason for this, if you're using two File Browsers on a remote session, is because whatever you do on your end, gets translated on the server end first. The server looks at the request and determines the shortest path to the destination and since it see's itself as the source and destination, the traffic never leaves the server (outside the updated tracking info you see for the file transfer).

If you're doing it through a complex remote session through a few computers, where you forcefully tunnel the traffic, then the transfer will happen over the network connection.

CIA
  • 1,604
  • 2
  • 13
  • 32
  • But if I open two file browser on a remote machine, I'm no longer using NFS. This is equivalent to `ssh mybox mv /path/to/file1/ /path/to/another/place` – alecail Oct 21 '13 at 19:27
  • If you have the shares mapped as NFS drives, then you are correct. If not, then no. – CIA Oct 21 '13 at 19:39