Make disk/disk copy slower
You can throttle a pipe with pv -qL
(or cstream -t
provides similar functionality)
tar -cf - . | pv -q -L 8192 | tar -C /your/usb -xvf -
-q
removes stderr progress reporting.
The -L
limit is in bytes.
More about the --rate-limit/-L
flag from the man pv
:
-L RATE, --rate-limit RATE
Limit the transfer to a maximum of RATE bytes per second.
A suffix of "k", "m", "g", or "t" can be added to denote
kilobytes (*1024), megabytes, and so on.
This answer originally pointed to throttle
but that project is no longer available so has slipped out of some package systems.
Instead of cp -a /foo /bar
you can also use rsync
and limit the bandwidth as you need.
From the rsync
's manual:
--bwlimit=KBPS
limit I/O bandwidth; KBytes per second
So, the actuall command, also showing the progress, would look like this:
rsync -av --bwlimit=100 --progress /foo /bar
I would assume you are trying not to disrupt other activity. Recent versions of Linux include ionice
which does allow you to control the scheduling of IO.
Besides allowing various priorities, there is an additional option to limit IO to times when the disk is otherwise idle. The command man ionice
will display the documentation.
Try copying the file using a command like:
ionice -c 3 cp largefile /new/directory
If the two directories are on the same device you may find linking the file does what you want. If you are copying for backup purposes, do not use this option. ln
is extremely fast as the file itself does not get copied. Try:
ln largefile /new/directory
Or if you just want to access it from a directory on a different device try:
ln -s largefile /new/directory