Search code examples
linuxperformanceiocentoscgroups

Restrict IO usage using cgroups


I am trying to restrict Io usage on my server using cgroups.

Here is my partition table info:

major minor  #blocks  name    
   8        0   10485760 sda
   8        1    9437184 sda1
   8        2    1047552 sda2

Here is my Filesystem structure:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       8.9G  8.4G   37M 100% /
none           1004M     0 1004M   0% /dev/shm

When i am trying to execute the following command:

echo "8:1 10485760" > /cgroup/blkio/test2/blkio.throttle.write_bps_device

I get the output as :

-bash: echo: write error: No such device

Here is my cgroups configuration:

mount { 
    blkio = /cgroup/blkio;      
}

group test2 {
    blkio {
        blkio.throttle.write_iops_device="";
        blkio.throttle.read_iops_device="";
        blkio.throttle.write_bps_device="";
        blkio.throttle.read_bps_device="";
        blkio.weight="";
        blkio.weight_device="";
    }
}

Why i can not restrict the /dev/sda1 IO usages?


Solution

  • You need to use the physical device when setting up blkio. Use the major:minor for the whole disk (8:0).