5

I have a Debian squeeze kernel (linux-image-2.6.32-5-openvz-amd64) which according to the Doku should support cgroups. When I look into the kernel configuration, it does (or is some other kernel configuration required?)

# zgrep -i cgroup /boot/config-2.6.32-5-openvz-amd64
# CONFIG_CGROUP_SCHED is not set
CONFIG_CGROUPS=y
# CONFIG_CGROUP_DEBUG is not set
CONFIG_CGROUP_DEVICE=y
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
CONFIG_NET_CLS_CGROUP=y

Also, according to http://wiki.debian.org/LXC, a kernel parameter cgroup_enable=memory might be necessary. I started the kernel with it:

# cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-2.6.32-5-openvz-amd64 root=UUID=6332fe39-7eaa-4519-b6c1-e05808284586 ro cgroup_enable=memory quiet console=ttyS0,57600n8

However, the system still has no cgroup support! The cgroup file system cannot be mounted as the file system type is not even known to the system:

# mount -t cgroup none /cgroup
mount: unknown filesystem type 'cgroup'

and:

# grep -i cgroup /proc/filesystems
#

So there is either a bug or I miss something. Can anyone tell me what? Is there a kernel parameter missing? A kernel configuration?

divB
  • 538
  • 1
  • 6
  • 22

3 Answers3

4

You have to pass an -o to tell it what to mount.

mount -t cgroup -o memory cgroup_memory /sys/fs/cgroup/memory

And that's assuming that /sys/fs/cgroup is mounted at all.

mount -t tmpfs cgroup /sys/fs/cgroup

Ubuntu has a package named cgroup-lite which can do all this at boot. It doesn't appear to be in Debian so I'm not sure what the equivalent might be.

Note: I cannot add comments so I have to simply answer your question this way. For example: I wanted to ask if you had checked your kernel logs (dmesg | grep cgroup).

Ken Sharp
  • 194
  • 10
3

You should mount like that[1]:

$ mount -t cgroup -o <cgroup_subsystem> name /cgroup/name

cgroup_subsystem can be[2]: {blkio, cpu, cpuacct, cpuset, devices, freezer, memory, net_cls, net_prio, ns}

You can also mount cgroups with the help of fstab (static information about the filesystems). Add this line to /etc/fstab to mount it at system boot with default cgroup subsystems.

$ cgroup  /sys/fs/cgroup  cgroup  defaults  0   0
emre can
  • 141
  • 3
  • Hi, What `name` would you put as the argument before the last one? I see in the other answer it could be `cgroup_memory`. Is that what you expect? – minghua Nov 01 '16 at 22:06
  • Ok, I found that the answer is in the kernel doc. The name is just something easy to remember and it is also put into `/proc/mounts`. – minghua Nov 02 '16 at 02:42
3

It depends on your distribution and kernel version. You can use following script from Docker to test cgroups and container related features:

wget https://raw.githubusercontent.com/docker/docker/master/contrib/check-config.sh -O cgroups_check && chmod +x cgroups_check
./cgroups_check
Tombart
  • 2,013
  • 3
  • 27
  • 47