I'm using tar do make backups of a machine. But, it is using a lot of I/O and slows down the whole machine.

So, is there a way to limit the read speed of tar?

I know about pv, but it limit only the write speed. Because I do incremental backups with tar --listed-incremental, this will work only with the first full backup (subsequent incremental backups will then consume a lot of read I/O if there is only small changes).

I've tried to lower the overall priority of the backup with a combination of nice and ionice, but this not really change anything.

Informations: it's Debian 9 machine, and the files are residing on an ext4 file-system on top of a LVM volume.

  • 2
    As a side note, sorry if I'm not posting the question on the right website. I'm a bit confused about the difference between unix.stackexchange, Super User and Server Fault since this question seems to be on-topic for these 3 websites. – Zoddo Dec 16 '18 at 12:01
  • 1
    check out cpulimit as in this answer: unix.stackexchange.com/a/39730/3375 – ojblass Dec 16 '18 at 12:27
  • Have you tried limiting the output of tar using something like pv, as you mentioned? – Andrew Henle Dec 16 '18 at 21:53
  • Be careful, gtar in general is unable to restore it's incremental backups. This only works in case that the differences between two incrementals are trivial and do not include renamed directories. – schily Dec 17 '18 at 16:23

You can run your tar command using ionice. Like this:

ionice -c3 tar --listed-incremental [...]

This will let the tar process only do I/O when there is no other process waiting for I/O.

In Debian the ionice utility is in the package util-linux, so you you may need to install that first.

Like with the normal (cpu) nice utility, the I/O scheduler class of a process is inherited by its child processes. When I'm planning to do resource-heavy stuff, I do not want users have their I/O slowed down because of it. I often start my shell this way:

nice ionice -c3 bash

Then everything I do from that shell will be very, very nice :)


Use cgroups

mkdir -p /sys/fs/cgroup/blkio/g1
echo "8:0 1048576" > /sys/fs/cgroup/blkio/g1/blkio.throttle.read_bps_device
pgrep -f tar > /sys/fs/cgroup/blkio/g1/cgroup.procs


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.