The keyword is bandwidth management and the Linux Kernel has direct support of it. I dealed with this long time ago and have forgotten much about that but there is a great online book that covers the topic extensively. It's called
To get a foretaste of what you want to achieve take a look at
Perhaps there are (software) servers which support bandwidth control directly!?
Supplement:
Are you using a 64-bit version of Linux with a lot of memory? In that case the problem could be that Linux can lock for minutes on big writes on slow devices like for
example SD cards or USB sticks. It's a known bug that should be fixed in newer kernels.
See http://lwn.net/Articles/572911/
Workaround: as root issue:
echo $((16*1024*1024)) > /proc/sys/vm/dirty_background_bytes
echo $((48*1024*1024)) > /proc/sys/vm/dirty_bytes
I have added it to my /etc/rc.local
file in my 64bit machines.
TANSTAAFL; this change can (and probably will) reduce your throughput to these devices --- it's a compromise between latency and speed. To get back to the previous behavior you can
echo 0 > /proc/sys/vm/dirty_background_bytes
echo 0 > /proc/sys/vm/dirty_bytes
...which are the default values, meaning that the writeback behavior will be controlled by the parameters dirty_ratio
and dirty_background_ratio
.
Note for the not-so-expert-with-linux people: the files in /proc
are pseudofiles --- just communication channels between the kernel and user space. Never use an editor to change or look at them; get instead a shell prompt --- for example, with sudo -i
(Ubuntu flavors) or su root
and use echo
and cat
).
Update 2016/04/18 it seems that, after all, the problem is still here. You can look at it at LWN.net, in this article about writeback queues.
Best Answer
You could use
pv
:The
-L
flag limits the throughput to 5 megabytes per second.pv
also writes to the stdout so you have to redirect to the target with>
.