ionice (util-linux) sets the I/O scheduling class and priority for a command or an existing process, similar to how nice/renice work for CPU scheduling.
ionice -c2 -n7 rsync -a /src/ /dest/ # run rsync at best-effort, lowest priority
ionice -c3 tar czf backup.tar.gz /data # class 3 = idle: only runs when nothing else needs the disk
sudo ionice -p 4821 # show a running process's current class/priority
sudo ionice -c2 -n0 -p 4821 # raise an existing process's priority (best-effort, highest)
| Class | Meaning |
|---|---|
| 1 (real time) | highest; can starve other I/O. Root only |
| 2 (best-effort, default) | takes a priority -n 0 (highest) to -n 7 (lowest) |
| 3 (idle) | only gets I/O when the device is otherwise idle |
It has visible effect mainly with the CFQ or BFQ I/O schedulers; on many modern setups using none/mq-deadline for NVMe, effects are smaller. Check the active scheduler: cat /sys/block/sda/queue/scheduler. Pairs naturally with nice/renice for CPU, and with rsync backup jobs from cron so they do not compete with foreground work.