Ionice Command

CFQ I/O disk elevator includes a tool called ionice which helps the administrator to assign priorities on a process level to speed up or to restrict the disk subsystem utilization of a specific process. For example if you want to run a rsync command or script to backup your files either locally or remotely just use ionice alone with the rsync syntax to speed up or restrict the rsync process.

Note : ionice is packed with util-linux rpm.

Ionice priorities

IDLE : A process with the assigned I/O priority idle will only be granted access to the disk subsystems if no other processes with a priority of best-effort or higher request access to data. Very useful to run tasks suck as updatedb.

BEST-EFFORT: As a default all processes that do not request a specific I/O priority are assigned to this class. Processes will inherit 8 levels of the priority of their respective CPU nice level to the I/O priority class.

REAL TIME: The highest available I/O priority is real time meaning that the respective process will always be given priority access to the disk subsystem. The real time priority setting can also accept 8 priority levels.

The ionice tool accepts the following options:

-c<#> I/O priority1 for real time, 2 for best-effort, 3 for idle

-n<#> I/O priority class data 0 to 7

-p<#> process id of a running task, use without -p to start a task with the respective I/O priority

Ionice examples

To assign an idle I/O priority to the running process with the PID for example 2939.

  • # ionice -c3 -p2939

To start an command/process with idle I/O priority (for example updatedb)

  • # ionice -c3 updatedb &

Speeding up the disk dumps using best effort scheduling (2) and 7 priority

  • # ionice -c2 -n7 PID (or) /path/backupscript.sh

Once you have scheduled the I/O priority you can check it using (for example PID 2939)

  • # ionice -p 2939

Ionice status

Useful links :

How to change the disk elevator on Linux

Monitoring disk I/O’s using Iotop