Système de fichiers

A hierarchy is created by mounting an instance of the cgroup filesystem with each of the desired subsystems listed as a mount option. For instance,

mount -t cgroup -o devices,memory,freezer cgroup /cgroup1

would instantiate a hierarchy with the devices and memory cgroups comounted. A child cgroup "child1" can be created using 'mkdir'

mkdir /cgroup1/child1

and tasks can be moved into the new child cgroup by writing their process IDs into the 'tasks' or 'cgroup.procs' file:

sleep 100 & echo $! > /cgroup1/child1/cgroup.procs

Other administration is done through files in the cgroup directories. For instance, to freeze all tasks in child1,

echo FROZEN > /cgroup1/child1/freezer.state

A great deal of information about cgroups and its subsystems can be found under the cgroups documentation directory in the kernel source tree (see Resources).