From 674caf31a70b2f7456bf0cabd71792d21511660c Mon Sep 17 00:00:00 2001 From: NezSez Date: Wed, 9 Mar 2022 17:32:59 -0500 Subject: [PATCH 1/5] Gemstone: Create view_kernel_conf.md New Gemstone file on viewing the .config settings at compile time for installed kernels. Closes rocky-linux/documentation#602 --- docs/gemstones/view_kernel_conf.md | 37 ++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 docs/gemstones/view_kernel_conf.md diff --git a/docs/gemstones/view_kernel_conf.md b/docs/gemstones/view_kernel_conf.md new file mode 100644 index 0000000000..2a898a4abe --- /dev/null +++ b/docs/gemstones/view_kernel_conf.md @@ -0,0 +1,37 @@ +--- +title: View Current Kernel Configuration +author: David Hensley +contributors: +tested with: 8.5 +tags: + - config + - kernel +update: 09-Mar-2022 +--- + +All linux distributions store the config used to compile the kernel as an ASCII file in: +```bash +/lib/modules//build/.config +``` +You can examine them to make sure that kernel was compiled with the support functions you need. +For the currently running kernel: +```bash +cat /lib/modules/$(uname -r)/build/.config | grep -i +``` +RHEL and derivative distributions (Fedora, CentOS Stream, Scientific Linux, RockyLinux, Almalinux, et. al.) +also store the config used for bootable installed kernels in the `/boot` directory as ASCII files: +```bash +/boot/config- +``` +To check the currently running kernel config for a particular value: +```bash +cat /boot/config-$(uname -r) | grep -i +``` +It will show "=m" (compiled in as a kernel module), or "=y" (compiled statically into the kernel) if configured, but doesn't have entries for anything **NOT** configured +(i.e. it will not show "=n"(not compiled in at all)) + +Some distibutions use `/proc/config.gz` by default instead: +```bash +zcat /proc/config.gz | grep -i +zgrep /proc/config.gz +``` From d5b54ebe79a12e49f8da311041e37650cd42d972 Mon Sep 17 00:00:00 2001 From: NezSez Date: Wed, 9 Mar 2022 20:41:28 -0500 Subject: [PATCH 2/5] List two distributions for config.gz Add two examples, Gentoo and Arch --- docs/gemstones/view_kernel_conf.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/gemstones/view_kernel_conf.md b/docs/gemstones/view_kernel_conf.md index 2a898a4abe..dc149d6870 100644 --- a/docs/gemstones/view_kernel_conf.md +++ b/docs/gemstones/view_kernel_conf.md @@ -27,10 +27,13 @@ To check the currently running kernel config for a particular value: ```bash cat /boot/config-$(uname -r) | grep -i ``` -It will show "=m" (compiled in as a kernel module), or "=y" (compiled statically into the kernel) if configured, but doesn't have entries for anything **NOT** configured +Results will show + "=m" if compiled in as a kernel module + "=y" if compiled statically into the kernel + doesn't have entries for anything **NOT** configured (i.e. it will not show "=n"(not compiled in at all)) -Some distibutions use `/proc/config.gz` by default instead: +Some distibutions, like Gentoo and Arch, use `/proc/config.gz` by default instead: ```bash zcat /proc/config.gz | grep -i zgrep /proc/config.gz From faac2edbedf61f7c23577cea81ccaff9128b1714 Mon Sep 17 00:00:00 2001 From: NezSez Date: Wed, 9 Mar 2022 20:49:55 -0500 Subject: [PATCH 3/5] Clarify results --- docs/gemstones/view_kernel_conf.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/gemstones/view_kernel_conf.md b/docs/gemstones/view_kernel_conf.md index dc149d6870..1b577e8ce3 100644 --- a/docs/gemstones/view_kernel_conf.md +++ b/docs/gemstones/view_kernel_conf.md @@ -28,12 +28,11 @@ To check the currently running kernel config for a particular value: cat /boot/config-$(uname -r) | grep -i ``` Results will show - "=m" if compiled in as a kernel module - "=y" if compiled statically into the kernel - doesn't have entries for anything **NOT** configured -(i.e. it will not show "=n"(not compiled in at all)) + - "=m" if compiled in as a kernel module + - "=y" if compiled statically into the kernel + - "is not set" if the setting exists but is not enabled (a boolean) -Some distibutions, like Gentoo and Arch, use `/proc/config.gz` by default instead: +Some distributions, like Gentoo and Arch, use `/proc/config.gz` by default instead: ```bash zcat /proc/config.gz | grep -i zgrep /proc/config.gz From 0dd0774cc2ba4f4fdf37e7c6f03170df3e674b3a Mon Sep 17 00:00:00 2001 From: NezSez Date: Thu, 10 Mar 2022 00:07:52 -0500 Subject: [PATCH 4/5] Update view_kernel_conf.md Re-worded for Wale's comments, added some extra info --- docs/gemstones/view_kernel_conf.md | 33 +++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/docs/gemstones/view_kernel_conf.md b/docs/gemstones/view_kernel_conf.md index 1b577e8ce3..654d8ab175 100644 --- a/docs/gemstones/view_kernel_conf.md +++ b/docs/gemstones/view_kernel_conf.md @@ -8,16 +8,26 @@ tags: - kernel update: 09-Mar-2022 --- - +You can see what your current kernel release is with: +```bash +uname -r +``` All linux distributions store the config used to compile the kernel as an ASCII file in: ```bash /lib/modules//build/.config ``` -You can examine them to make sure that kernel was compiled with the support functions you need. -For the currently running kernel: +and a list of various kernel objects, including builtin and loadable modules in: +```bash +/sys/module/ +``` +You can examine them to make sure the currently running kernel was compiled with the functions you need: ```bash cat /lib/modules/$(uname -r)/build/.config | grep -i ``` +or +```bash +ls /sys/module/ | grep -i +``` RHEL and derivative distributions (Fedora, CentOS Stream, Scientific Linux, RockyLinux, Almalinux, et. al.) also store the config used for bootable installed kernels in the `/boot` directory as ASCII files: ```bash @@ -31,9 +41,26 @@ Results will show - "=m" if compiled in as a kernel module - "=y" if compiled statically into the kernel - "is not set" if the setting exists but is not enabled (a boolean) +If your search yields no results then the element you are looking for may depend on another config element which +isn't set. Some distributions, like Gentoo and Arch, use `/proc/config.gz` by default instead: ```bash zcat /proc/config.gz | grep -i zgrep /proc/config.gz ``` + +For any distribution, if your running kernel has both +``` +CONFIG_IKCONFIG +CONFIG_IKCONFIG_PROC +``` +set in its config, and if +```bash +ls /sys/module/configs +``` +exists and is executable (searchable in the case of a dir) +then you can create `/proc/config.gz` with this command: +```bash +modprobe configs +``` From e8aa0a7e7474dade2627a6adbdce1b6d8e390c56 Mon Sep 17 00:00:00 2001 From: NezSez Date: Fri, 11 Mar 2022 15:08:02 -0500 Subject: [PATCH 5/5] Update view_kernel_conf.md --- docs/gemstones/view_kernel_conf.md | 48 ++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/docs/gemstones/view_kernel_conf.md b/docs/gemstones/view_kernel_conf.md index 654d8ab175..1309af8911 100644 --- a/docs/gemstones/view_kernel_conf.md +++ b/docs/gemstones/view_kernel_conf.md @@ -4,30 +4,43 @@ author: David Hensley contributors: tested with: 8.5 tags: - - config - kernel + - config + - modules + - kmod update: 09-Mar-2022 --- -You can see what your current kernel release is with: -```bash -uname -r -``` -All linux distributions store the config used to compile the kernel as an ASCII file in: +The Linux kernel stores running kernel information in two places via special filesystems located in memory: + - The older [procfs](https://man7.org/linux/man-pages/man5/procfs.5.html) which mounts `/proc` (verify via `mount -l -t proc`) + - The newer [sysfs](https://man7.org/linux/man-pages/man5/sysfs.5.html) which mounts `/sys` (verify via `mount -l -t sysfs`) + +[Concise summary](https://www.landoflinux.com/linux_procfs_sysfs.html) of them and what info they contain. + +Linux distributions store the config used to compile the kernel as an ASCII file in: ```bash /lib/modules//build/.config ``` -and a list of various kernel objects, including builtin and loadable modules in: +Configured builtin (statically compiled in) and loadable modules for the currently running kernel are listed by directories named for the modules in: ```bash /sys/module/ ``` -You can examine them to make sure the currently running kernel was compiled with the functions you need: -```bash -cat /lib/modules/$(uname -r)/build/.config | grep -i -``` -or +See what your currently running "kernel release" version is with: + +`uname -r` and substitute its value in commands with `$(uname -r)` + +You can examine these files to make sure the currently running kernel was compiled with the functions you need: + - `cat /lib/modules/$(uname -r)/build/.config | grep -i ` + - `ls /sys/module/ | grep -i ` + - `sysctl -a | grep -i ` + - `lsmod | grep -i ` + - `modinfo ` + +You can check for kernel module dependencies in: ```bash -ls /sys/module/ | grep -i +/lib/modules//modules.dep ``` +but it is easier to read the output of the "Used-by" field in `lsmod`. + RHEL and derivative distributions (Fedora, CentOS Stream, Scientific Linux, RockyLinux, Almalinux, et. al.) also store the config used for bootable installed kernels in the `/boot` directory as ASCII files: ```bash @@ -42,7 +55,7 @@ Results will show - "=y" if compiled statically into the kernel - "is not set" if the setting exists but is not enabled (a boolean) If your search yields no results then the element you are looking for may depend on another config element which -isn't set. +isn't set (check this with `lsmod`). Some distributions, like Gentoo and Arch, use `/proc/config.gz` by default instead: ```bash @@ -50,12 +63,12 @@ zcat /proc/config.gz | grep -i zgrep /proc/config.gz ``` -For any distribution, if your running kernel has both +For any distribution, if your running kernel has set both ``` CONFIG_IKCONFIG CONFIG_IKCONFIG_PROC ``` -set in its config, and if +and if ```bash ls /sys/module/configs ``` @@ -64,3 +77,6 @@ then you can create `/proc/config.gz` with this command: ```bash modprobe configs ``` +### Reference: + +[sysctl](https://man7.org/linux/man-pages/man8/sysctl.8.html), [lsmod](https://man7.org/linux/man-pages/man8/lsmod.8.html), [modinfo](https://man7.org/linux/man-pages/man8/modinfo.8.html), [modprobe](https://man7.org/linux/man-pages/man8/modprobe.8.html), [depmod](https://man7.org/linux/man-pages/man8/depmod.8.html), [modules.dep](https://man7.org/linux/man-pages/man5/modules.dep.5.html), [procfs](https://man7.org/linux/man-pages/man5/procfs.5.html), [sysfs](https://man7.org/linux/man-pages/man5/sysfs.5.html), [uname](https://man7.org/linux/man-pages/man8/uname26.8.html)