Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Red Hat Enterprise Linux 9 Essentials Book now available.

Purchase a copy of Red Hat Enterprise Linux 9 (RHEL 9) Essentials

Red Hat Enterprise Linux 9 Essentials Print and eBook (PDF) editions contain 34 chapters and 298 pages

Preview Book

2.5. Creating Cgroups

Use the cgcreate command to create cgroups. The syntax for cgcreate is: cgcreate -t uid:gid -a uid:gid -g subsystems:path , where:
  • -t (optional) — specifies a user (by user ID, uid) and a group (by group ID, gid) to own the tasks pseudofile for this control group. This user can add tasks to the control group.

    Note — Removing tasks

    Note that the only way to remove a task from a control group is to move it to a different control group. To move a task, the user must have write access to the destination control group; write access to the source control group is unimportant.
  • -a (optional) — specifies a user (by user ID, uid) and a group (by group ID, gid) to own all pseudofiles other than tasks for this control group. This user can modify the access that the tasks in this control group have to system resources.
  • -g — specifies the hierarchy in which the cgroup should be created, as a comma-separated list of the subsystems associated with those hierarchies. If the subsystems in this list are in different hierarchies, the group is created in each of these hierarchies. The list of hierarchies is followed by a colon and the path to the child group relative to the hierarchy. Do not include the hierarchy mount point in the path.
    For example, the control group located in the directory /cgroup/cpu_and_mem/lab1/ is called just lab1 — its path is already uniquely determined because there is at most one hierarchy for a given subsystem. Note also that the group is controlled by all the subsystems that exist in the hierarchies in which the cgroup is created, even though these subsystems have not been specified in the cgcreate command — refer to Example 2.3, “cgcreate usage”.
Because all control groups in the same hierarchy have the same controllers, the child group has the same controllers as its parent.
Example 2.3. cgcreate usage
Consider a system where the cpu and memory subsystems are mounted together in the cpu_and_mem hierarchy, and the net_cls controller is mounted in a separate hierarchy called net. We now run:
cgcreate -g cpu,net_cls:/test-subgroup
The cgcreate command creates two groups named test-subgroup, one in the cpu_and_mem hierarchy and one in the net hierarchy. The test-subgroup group in the cpu_and_mem hierarchy is controlled by the memory subsystem, even though we did not specify it in the cgcreate command.

Alternative method

To create a child of the control group directly, use the mkdir command:
mkdir /cgroup/hierarchy/name/child_name
For example:
mkdir /cgroup/cpuset/lab1/group1

 
 
  Published under the terms of the Creative Commons License Design by Interspire