3

I am trying to limit memory usage for a LXC container using CGroups, but I can't limit the memory.

# lxc-cgroup -n maxdaniel981 memory.limit_in_bytes 134217728
lxc_container: failed to assign '134217728' value to 'memory.limit_in_bytes' for 'maxdaniel981'

Then I looked up /proc/cgroups:

# cat /proc/cgroups
#subsys_name    hierarchy       num_cgroups     enabled
cpuset  2       3       1
cpu     3       3       1
cpuacct 3       3       1
memory  0       1       0
devices 4       3       1
freezer 5       3       1
net_cls 6       3       1
blkio   7       3       1
perf_event      8       3       1
net_prio        6       3       1

It looks like cgroups_memory is disabled, but I enabled the kernel flag in /etc/default/grub and updated grub using update-grub

# cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="cggroup_enable=memory swapaccount=1"
GRUB_CMDLINE_LINUX="cggroup_enable=memory swapaccount=1"

CGroup is mounted in /etc/fstab like this;

cgroup        /sys/fs/cgroup  cgroup  defaults        0       0

Can somebody help me with this issue? I am using Debian Jessie, and my kernel version is 3.16.0-4-amd64.

4
+50

There's a small typo in your GRUB configuration; cgroup not cggroup should do the trick:

GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory swapaccount=1"
  • Thank you, I don't know how I could have missed that.... (I have to wait 15 hours to reward the bounty). – maxdaniel98 Mar 10 '16 at 7:38
  • 2
    Good catch! +1 from me for this answer - but also +1 for the question, for showing us the relevant code, instead of just telling us "I enabled the kernel flag in grub", or somesuch. I wish more questions were so concisely but informatively written. – MadHatter Mar 10 '16 at 7:58
  • @MadHatter Thanks! I completely agree with you. I rarely ask questions, much of what I need to know is already on these forums. And, this also may help others with the same question or problem. – maxdaniel98 Mar 10 '16 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.