From 50e7c101af99371e36e1f86a4bc9e64ced81d14d Mon Sep 17 00:00:00 2001 From: NezSez Date: Wed, 16 Mar 2022 03:19:10 -0400 Subject: [PATCH 1/2] Rewrite of view_kernel_conf.md Various improvements. Still WIP at this point. --- docs/gemstones/view_kernel_conf.md | 143 ++++++++++++++++++++--------- 1 file changed, 102 insertions(+), 41 deletions(-) diff --git a/docs/gemstones/view_kernel_conf.md b/docs/gemstones/view_kernel_conf.md index 30ee336bf7..2e15185f96 100644 --- a/docs/gemstones/view_kernel_conf.md +++ b/docs/gemstones/view_kernel_conf.md @@ -12,86 +12,147 @@ tags: # View Current Kernel Configuration -The Linux kernel stores running kernel information in two places via special filesystems located in memory: +The Linux kernel stores running kernel information in two places via special filesystems: ([A summary of them](https://www.landoflinux.com/linux_procfs_sysfs.html)) + - 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`) + - The newer [sysfs](https://man7.org/linux/man-pages/man5/sysfs.5.html) which mounts `/sys` (verify via `mount -l -t sysfs`) + +!!! caution + + Be cautious if examining the files mentioned here, altering them can change the behavoir of the actual running kernel! + + +These two interfaces allow you to view and change the parameters of the currently running kernel. +Note that if you do an [`ls -l`](https://man7.org/linux/man-pages/man1/ls.1.html) on some of these files, they will show as "0" length, but if you [`cat`](https://man7.org/linux/man-pages/man1/cat.1.html) them out they actually contain data; most of them are +ASCII and editable, however some are binary, and in either case commands like [`file`](https://man7.org/linux/man-pages/man1/file.1.html) or [`stat`](https://man7.org/linux/man-pages/man2/lstat.2.html) will typically just return "empty file" or "0" for lengths, although they will show you other information. -[Concise summary](https://www.landoflinux.com/linux_procfs_sysfs.html) of them and what info they contain. +The preferred and standard programs for interacting with these provided functions are [`lsmod`](https://man7.org/linux/man-pages/man8/lsmod.8.html), [`modinfo`](https://man7.org/linux/man-pages/man8/modinfo.8.html) and [`sysctl`](https://man7.org/linux/man-pages/man8/sysctl.8.html), among others. -Linux distributions store the config used to compile the kernel as an ASCII file in: +See what your currently running "kernel release" version is with: + +`uname -r` and substitute its return value in commands by using `$(uname -r)` + +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 used by Grub2 as ASCII files: ```bash -/lib/modules//build/.config +/boot/config- ``` -Configured builtin (statically compiled in) and loadable modules for the currently running kernel are listed by directories named for the modules in: +To check the currently running kernel config for a particular value: ```bash -/sys/module/ +cat /boot/config-$(uname -r) | grep -i ``` -See what your currently running "kernel release" version is with: +Results will show: + - "=m" if compiled in as a kernel module + - "=y" if compiled statically into the kernel + - "is not set" if that setting was commented out + - a numeric value + - a quoted string value -`uname -r` and substitute its value in commands with `$(uname -r)` +Some distributions, like Gentoo and Arch, use the `configs` kernel module to provide `/proc/config.gz` by default instead: -You can examine these files to make sure the currently running kernel was compiled with the functions you need: +```bash +zcat /proc/config.gz | grep -i +zgrep /proc/config.gz +``` - - `cat /lib/modules/$(uname -r)/config | grep -i ` - - `ls /sys/module/ | grep -i ` - - `sysctl -a | grep -i ` - - `lsmod | grep -i ` - - `modinfo ` +For any distribution, if your running kernel has set both `CONFIG_IKCONFIG` and `CONFIG_IKCONFIG_PROC` +and if -You can check for kernel module dependencies in: +```bash +ls -lh /sys/module/configs +``` + +exists and is executable (searchable in the case of a dir) +then you can create `/proc/config.gz` with this command if it is not present: ```bash -/lib/modules//modules.dep +modprobe configs ``` -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: +!!! Enabled Repos: + + This document does not currently cover kernel packages that might have come from non-default repos such as: + appstream-debug, appstream-source, baseos-debug, baseos-source, or devel + + +The `kernel-devel` packages install the config file used to compile each installed standard kernel package as an ASCII file in the following location: ```bash -/boot/config- +/usr/src/kernels//.config ``` -To check the currently running kernel config for a particular value: + +This file is more commonly accessed by a symlinked path provided by the `kernel-core` packages: ```bash -cat /boot/config-$(uname -r) | grep -i +/lib/modules//build/ -> /usr/src/kernels// ``` -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 (check this with `lsmod`). +If you have `kernel-debug-devel` packages installed you will also have this directory: -Some distributions, like Gentoo and Arch, use `/proc/config.gz` by default instead: +```bash + /usr/src/kernels/+debug/ +``` + +You can look in any of the following for details on the config values used to build an installed kernel: ```bash -zcat /proc/config.gz | grep -i -zgrep /proc/config.gz +/lib/modules//config +/lib/modules//build/.config +/usr/src/kernels//.config +/usr/src/kernels/+debug/.config ``` -For any distribution, if your running kernel has set both +If using a debug kernel package the same info is in: +```bash +/lib/modules/+debug/build/.config +/usr/src/kernels/+debug/.config ``` -CONFIG_IKCONFIG -CONFIG_IKCONFIG_PROC + +Configured modules for the currently running kernel, whether compiled as builtin (i.e. statically into the kernel itself) or a loadable module are listed by sub directories named as the module name in: + +```bash +/sys/module/ ``` -and if +You can examine these files to make sure the currently running kernel was compiled with the functions you need depending on which packages you actually have installed: ```bash -ls /sys/module/configs +cat /lib/modules/$(uname -r)/config | grep -i ``` -exists and is executable (searchable in the case of a dir) -then you can create `/proc/config.gz` with this command: +```bash +cat /lib/modules/$(uname -r)/build/.config | grep -i +``` +```bash +cat /usr/src/kernels/$(uname -r)/.config | grep -i +``` +```bash +cat /usr/src/kernels/$(uname -r)+debug/.config | grep -i +``` +```bash +ls -lh /sys/module/ | grep -i +``` +```bash +sysctl -a | grep -i +``` +```bash +lsmod | grep -i +``` +```bash +modinfo +``` + +You can check for kernel module dependencies in the file: ```bash -modprobe configs +/lib/modules//modules.dep ``` + +but it is *MUCH* easier to read or parse the output of the "Used-by" field in [`lsmod`](https://man7.org/linux/man-pages/man8/lsmod.8.html). + ## 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) +[depmod](https://man7.org/linux/man-pages/man8/depmod.8.html), [ls](https://man7.org/linux/man-pages/man1/ls.1.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), [modules.dep](https://man7.org/linux/man-pages/man5/modules.dep.5.html), [namespaces](https://man7.org/linux/man-pages/man7/namespaces.7.html), [procfs](https://man7.org/linux/man-pages/man5/procfs.5.html), [sysctl](https://man7.org/linux/man-pages/man8/sysctl.8.html), [sysfs](https://man7.org/linux/man-pages/man5/sysfs.5.html), [uname](https://man7.org/linux/man-pages/man8/uname26.8.html) From d7a81255b8386a18a0bf0297a6ecf4722e02de8c Mon Sep 17 00:00:00 2001 From: NezSez Date: Wed, 16 Mar 2022 12:41:35 -0400 Subject: [PATCH 2/2] Place most useful info at top Put preferred cmds at top, details at bottom --- docs/gemstones/view_kernel_conf.md | 32 ++++++++++++------------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/docs/gemstones/view_kernel_conf.md b/docs/gemstones/view_kernel_conf.md index 2e15185f96..8d8d84ab32 100644 --- a/docs/gemstones/view_kernel_conf.md +++ b/docs/gemstones/view_kernel_conf.md @@ -26,7 +26,16 @@ These two interfaces allow you to view and change the parameters of the currentl Note that if you do an [`ls -l`](https://man7.org/linux/man-pages/man1/ls.1.html) on some of these files, they will show as "0" length, but if you [`cat`](https://man7.org/linux/man-pages/man1/cat.1.html) them out they actually contain data; most of them are ASCII and editable, however some are binary, and in either case commands like [`file`](https://man7.org/linux/man-pages/man1/file.1.html) or [`stat`](https://man7.org/linux/man-pages/man2/lstat.2.html) will typically just return "empty file" or "0" for lengths, although they will show you other information. -The preferred and standard programs for interacting with these provided functions are [`lsmod`](https://man7.org/linux/man-pages/man8/lsmod.8.html), [`modinfo`](https://man7.org/linux/man-pages/man8/modinfo.8.html) and [`sysctl`](https://man7.org/linux/man-pages/man8/sysctl.8.html), among others. +The preferred and standard programs for interacting with these functions are [`lsmod`](https://man7.org/linux/man-pages/man8/lsmod.8.html), [`modinfo`](https://man7.org/linux/man-pages/man8/modinfo.8.html) and [`sysctl`](https://man7.org/linux/man-pages/man8/sysctl.8.html), among others. +```bash +sysctl -a | grep -i +``` +```bash +lsmod | grep -i +``` +```bash +modinfo +``` See what your currently running "kernel release" version is with: @@ -106,20 +115,14 @@ You can look in any of the following for details on the config values used to bu /usr/src/kernels/+debug/.config ``` -If using a debug kernel package the same info is in: - -```bash -/lib/modules/+debug/build/.config -/usr/src/kernels/+debug/.config -``` - Configured modules for the currently running kernel, whether compiled as builtin (i.e. statically into the kernel itself) or a loadable module are listed by sub directories named as the module name in: ```bash /sys/module/ ``` -You can examine these files to make sure the currently running kernel was compiled with the functions you need depending on which packages you actually have installed: +For each installed kernel-release you can examine these files to see what values were compiled into that kernel, and what version of [GCC](https://man7.org/linux/man-pages/man1/gcc.1.html) was used to compile it: + ```bash cat /lib/modules/$(uname -r)/config | grep -i ``` @@ -135,15 +138,6 @@ cat /usr/src/kernels/$(uname -r)+debug/.config | grep -i ```bash ls -lh /sys/module/ | grep -i ``` -```bash -sysctl -a | grep -i -``` -```bash -lsmod | grep -i -``` -```bash -modinfo -``` You can check for kernel module dependencies in the file: @@ -151,7 +145,7 @@ You can check for kernel module dependencies in the file: /lib/modules//modules.dep ``` -but it is *MUCH* easier to read or parse the output of the "Used-by" field in [`lsmod`](https://man7.org/linux/man-pages/man8/lsmod.8.html). +but it is easier to read or parse the output of the "Used-by" field in [`lsmod`](https://man7.org/linux/man-pages/man8/lsmod.8.html). ## Reference: