How do I prevent a tar pipe from causing swapping?

Posted by Jeff Shattock on Super User See other posts from Super User or by Jeff Shattock
Published on 2010-05-13T18:03:40Z Indexed on 2010/05/13 18:14 UTC
Read the original article Hit count: 227

Filed under:
|
|
|

I have a rather large filesystem that I need to transfer from one Linux server to another. I figured the best way to do this was via a tar/netcat pipe arrangment, something like

tar c . | pv | nc blah blah blah

And it works great, the network stays fairly saturated, life is good. Until the source machine starts swapping.

The files are on a raid on the source system, so the read speed is much faster than the write speed on the other end. Since the dest machine hasnt picked up the data yet, the source machine needs to stick it somewhere, so into RAM it goes, until there is no more free RAM. It then starts swapping, which is horribly painful since that machine has its OS installed on a somewhat slow CF card.

Both machines have 4GB of physical ram, 64 bit Ubuntu 9.04 server. GigE link between them.

How do I prevent this swapping? Can I put a "speed-limit" on the tar or netcat process so that the transfer speed doesn't overwhelm the write throughput on the destination end? The man pages didn't list anything, but there might be something I'm overlooking.

© Super User or respective owner

Related posts about netcat

Related posts about tar