dsvi/chill

Run any command with a disk I/O bandwidth limit applied to every physical block device

★ 0Forks 0CGitHub ↗Compare

README

chill

Run any command with a disk I/O bandwidth limit applied to every physical block device on the system.

chill 10M rsync -av /data/ /backup/

The command runs at normal speed except that reads and writes to every real disk are capped at the given rate. The exit status of `chill` is the exit status of your command. Signals (Ctrl-C, `kill`, etc.) are forwarded to it, and if it dies from a signal, `chill` dies from the same one.

Useful for backups, downloads, builds, and anything else you don't want monopolizing the I/O.

Install

chill must be installed setuid root — it needs root only long enough to create a private cgroup and write the limit, then drops back to your user before running your command.

cc -Os -o chill chill.c
sudo install -o root -g root -m 4755 chill /usr/local/bin/chill

Usage

chill <bandwidth> <command> [args...]

bandwidth is bytes per second, optionally suffixed with K, M, G, or T (powers of 1024, like systemd):

chill 500K tar -cf - /home | ssh backup 'cat > home.tar'
chill 50M dd if=disk.img of=/dev/sdb bs=4M
chill 2M curl -O https://example.com/big.iso

The exit status of chill is the exit status of your command. Signals (Ctrl-C, kill, etc.) are forwarded to it, and if it dies from a signal, chill dies from the same one.

Requirements

  • Linux with cgroup v2 mounted at /sys/fs/cgroup
  • The io controller available (it is on any modern systemd distro)
  • Installed setuid root

If the io controller isn't enabled, chill refuses to run rather than letting your command run unthrottled.

Limitations

  • Block devices only. Network filesystems (NFS, SMB, sshfs, etc.), FUSE, and ZFS are not throttled — they don't go through the block layer that the IO controller manages.

  • Per-device, not aggregate. chill 10M with two active disks read means up to 20M/s total.

  • Cached reads aren't throttled.

Contributors

dsvi

Issues