How to identify if our linux kernel is build with a specific option or not, for example if cgroup option is enabled during kernel build or not ?

Sometimes when you browse solution to some issue, you might have seen “make sure your kernel supports —- option i.e. during its build, this option is specified and enabled ?”

So the answer lies in this article.

Today we will see a very useful tip to identify whether our kernel is built with some specific option or not.

1. First check out the current kernel through which our system is booted with.

[root@ngelinux cgroup]# uname -a
Linux ngelinux 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:39:32 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@ngelinux cgroup]# 

Hence our system is up with kernel version 3.10.0-957.

2. Check Kernel config file for options.
To know with which option this kernel is created, check out the config file kept inside /boot and grep the option you want to look for.

[root@ngelinux cgroup]# cat /boot/config-3.10.0-957.el7.x86_64 | grep -i cgroup
CONFIG_CGROUPS=y
# CONFIG_CGROUP_DEBUG is not set
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_PIDS=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_HUGETLB=y
CONFIG_CGROUP_PERF=y
CONFIG_CGROUP_SCHED=y
CONFIG_BLK_CGROUP=y
# CONFIG_DEBUG_BLK_CGROUP is not set
CONFIG_NETFILTER_XT_MATCH_CGROUP=m
CONFIG_NET_CLS_CGROUP=y
CONFIG_NETPRIO_CGROUP=y
[root@ngelinux cgroup]# 

We can see above most of the cgroup config is set and few of the options are not set.

3. An example: checking ikconfig option

[root@ngelinux cgroup]# cat /boot/config-3.10.0-957.el7.x86_64 | grep -i ikconfig
# CONFIG_IKCONFIG is not set

If our kernel was built with IKCONFIG_PROC option set, we can check out the configuration from /proc/config.gz file as it is built with IKCONFIG enabled, and then we can extract it from kernel image by using extract-ikconfig script.

4. Verifying if our kernel supports CGROUPs.
To use crgroups and its features, our kernel must built with option CONFIG_CGROUP.
We can see above that our kernel is built with this option enabled and hence CGROUPs are supported.

[root@ngelinux cgroup]# cat /boot/config-3.10.0-957.el7.x86_64 | grep -i cgroup
CONFIG_CGROUPS=y
  • Each CGROUP v1 controller has an associated configuration option that must be set in order to use that controller.
    Each controller must be mounted against a cgroup filesystem.
    Such mounts go under tmpfs filesystem mounted at /sys/fs/cgroup.
  • For example:- We can mount cpu controller as follows:
    # mount -t cgroup -o cpu none /sys/fs/cgroup/cpu

Leave a Reply

avatar
  Subscribe  
Notify of