LXC on Linux From Scratch | cgroups driver issue

Hi,

I am trying to use LXC on Linux From Scratch. I have built LXC from source. I have enabled cgroups in Kernel config. I have created an Ubuntu container using the following command.
" $ lxc-create --template download --name test_ubuntu ". When I start the container, using lxc-start command, I get an error saying that the system has failed to initialize cgroups. Here are the configurations of my machine.

OS: Linux From Scratch - 11.0
Kernel version: 5.10.106
CPU Architecture: amd
LXC Version: 4.0.0-devel

LXC download link: GitHub - lxc/lxc: LXC - Linux Containers

Here are the contents of logfile that contains the error info.
logfile:
lxc-start test_ubuntu 20220325005625.515 TRACE commands - commands.c:lxc_cmd:513 - Connection refused - Command “get_init_pid” failed to connect command socket
lxc-start test_ubuntu 20220325005625.515 TRACE commands - commands.c:lxc_cmd:513 - Connection refused - Command “get_state” failed to connect command socket
lxc-start test_ubuntu 20220325005625.515 TRACE commands - commands.c:lxc_server_init:2078 - Created abstract unix socket “/usr/local/var/lib/lxc/test_ubuntu/command”
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_init_handler:757 - Unix domain socket 4 for command server is ready
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_start:2188 - Doing lxc_start
lxc-start test_ubuntu 20220325005625.515 INFO lsm - lsm/lsm.c:lsm_init_static:38 - Initialized LSM security driver nop
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_init:781 - Initialized LSM
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_serve_state_clients:486 - Set container state to STARTING
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_serve_state_clients:489 - No state clients registered
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_init:787 - Set container state to “STARTING”
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_init:843 - Set environment variables
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_init:848 - Ran pre-start hooks
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:setup_signal_fd:373 - Created signal file descriptor 6
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_init:861 - Set up signal fd
lxc-start test_ubuntu 20220325005625.515 ERROR cgfsng - cgroups/cgfsng.c:initialize_cgroups:3434 - Cannot allocate memory - Failed to initialize cgroups
lxc-start test_ubuntu 20220325005625.515 ERROR cgroup - cgroups/cgroup.c:cgroup_init:33 - Bad file descriptor - Failed to initialize cgroup driver
lxc-start test_ubuntu 20220325005625.515 ERROR start - start.c:lxc_init:865 - Failed to initialize cgroup driver
lxc-start test_ubuntu 20220325005625.515 ERROR start - start.c:__lxc_start:2008 - Failed to initialize container “test_ubuntu”
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_serve_state_clients:486 - Set container state to ABORTING
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_serve_state_clients:489 - No state clients registered
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_serve_state_clients:486 - Set container state to STOPPING
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_serve_state_clients:489 - No state clients registered
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_end:966 - Closed command socket
lxc-start test_ubuntu 20220325005625.515 TRACE start - start.c:lxc_end:977 - Set container state to “STOPPED”
lxc-start test_ubuntu 20220325005625.515 ERROR lxc_start - tools/lxc_start.c:main:306 - The container failed to start
lxc-start test_ubuntu 20220325005625.515 ERROR lxc_start - tools/lxc_start.c:main:311 - Additional information can be obtained by setting the --logfile and --logpriority options

Could anyone help me out here and let me know what could be the possible fix or solution for this.

Thanks,
Sai Kiran.

You need to have a cgroup1 or cgroup2 tree at /sys/fs/cgroup with at least the freezer cgroup controller working.

I see that cgroup tree is missing under the folder /sys/fs/cgroup. Could you please let me know what needs to be done to get the folder? I have just started using LXC and I am not sure how to get the freezer cgroup controller working.

Hi,

I have created the necessary cgroup tree structure under /sys/fs/cgroup folder. I have mounted cgroup freezer, devices, cpuset and other drivers using the following command.

$ mkdir /sys/fs/cgroup/freezer
$ mount -t cgroup freezer -o freezer /sys/fs/cgroup/freezer

Since I do not have systemd, I have to use the following command, in order to start the container.
$ mount -t cgroup cgroup -o none,name=systemd /sys/fs/cgroup/systemd
$ lxc-start ubuntu -F

I am able to run the container now. Thanks for your inputs @stgraber .