Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Throttle disk I/O in Ubuntu 15.04+ / Debian 8 / other distributions with systemd
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Throttle disk I/O in Ubuntu 15.04+ / Debian 8 / other distributions with systemd

perennateperennate Member, Host Rep

systemd provides a convenient wrapper around the cgroups kernel feature that allows you to control various cgroups and other properties: http://www.freedesktop.org/software/systemd/man/systemd.resource-control.html

One application of this is throttling disk I/O of a process. Using systemd-run, we can run a command and specify the resource control and other properties:

systemd-run -p 'PropertyName=blah' command to run

Read the man pages:

man systemd-run
man systemd.resource-control

In particular, we can use the BlockIOReadBandwidth and BlockIOWriteBandwidth resource control properties to limit the disk bandwidth available to the process. For example, this execution will limit dd to 4MB/s:

systemd-run -p BlockIOReadBandwidth='/dev/vda1 4M' -p BlockIOWriteBandwidth='/dev/vda1 4M' dd if=/dev/zero of=/root/test bs=64k count=16k oflag=dsync

Of course, replace /dev/vda1 with the relevant partition that is mounted (use "findmnt /" if you're not sure).

Sign In or Register to comment.