Cgroups - howto

From Skytech
Revision as of 11:36, 20 September 2014 by Martin (talk | contribs)
Jump to navigation Jump to search


Howto - cgroups

This is only for debian wheezy

Prereq

apt-get install cgroup-bin 

Enable cgroups memory configuration

This is disabled by default in wheezy (installed though), so activate via:

vim /etc/default/grub
# Add cgroup_enable=memory to GRUB_CMDLINE_KERNEL:
GRUB_CMDLINE_LINUX="cgroup_enable=memory"
update-grub2

Mount cgroups

Add to /etc/fstab

cgroup  /sys/fs/cgroup  cgroup  defaults  0   0

Create cgroup owner(s)

sudo cgcreate -a ipeacocks -g cpu:ipeacocks
  • Adding ressources to that user. A CPU is divided into 1024 slices, so assigning 100 for a user would equal ~10%.
# About 10 % cpu
echo 100 > /cgroup/cpu/$USER/cpu.shares

# 10 Mb
echo 10000000 > /cgroup/memory/$USER/memory.limit_in_bytes