2018-04-12 21:03:44 +00:00
= Troubleshooting
2023-08-12 12:15:10 +00:00
Brandon Nielsen; Jibec
:revnumber: unknown
:revdate: 2021-02-22
:category: Kernel
2023-08-24 16:16:15 +00:00
:tags: How-to, Kernel, Troubleshooting
:page-aliases: kernel/troubleshooting.adoc
2018-04-12 21:03:44 +00:00
2019-03-20 22:42:41 +00:00
2023-08-12 12:15:10 +00:00
The kernel, like any software, has bugs. It's a large, complex project and can be difficult to troubleshoot problems. This document covers some basic troubleshooting techniques to help narrow down the root cause of an issue.
2018-04-12 21:03:44 +00:00
== Boot failures
Sometimes the kernel fails to boot. Depending on where the problem is in the
boot process, there may or may not be any output. Some good first steps are:
* Remove `quiet` (enable more log messages) and `rhgb` (disable graphical boot)
from the boot flags. If the text output is too fast to read, add
`boot_delay=1000` (the number of milliseconds to delay in
between printk during boot). You can use a camera to take pictures of the
output.
* Booting with vga=791 (or even just vga=1 if the video card won't support 791)
will put the framebuffer into high resolution mode to get more lines of text
on screen, allowing more context for bug analysis.
* Add `initcall_debug` parameter, which traces the initcalls as they are
executed.
2018-04-17 19:54:26 +00:00
* If you get no output at all from the kernel, booting with `earlyprintk=vga`
can sometimes yield something of interest.
2018-04-12 21:03:44 +00:00
== Hangs and freezes
* Checking whether or not the CapsLock key (or NumLock or ScrollLock) causes
the light on the keyboard to change state can be used as an indication of
whether or not the kernel has hung completely, or if there is something else
going on.
* The SysRq magic keys may still work. You may need to add
2020-04-18 21:27:08 +00:00
`sysrq_always_enabled=1` to the kernel boot command line. See
https://fedoraproject.org/wiki/QA/Sysrq[the wiki article on SysRq on usage
details].
2018-04-12 21:03:44 +00:00
* Setting `nmi_watchdog=1` on the kernel command line will cause a panic when
2020-04-18 21:27:08 +00:00
an NMI watchdog timeout occurs.
2018-04-12 21:03:44 +00:00
2018-06-19 19:49:52 +00:00
== Logs to collect ==
2018-04-12 21:03:44 +00:00
2018-06-19 19:49:52 +00:00
When reporting an issue with the kernel you should always attach the kernel
logs, usually collected with the `dmesg` command. For some types of issues,
you may need to collect more logs.
=== Input issues (touchpad etc.) ===
2021-02-23 01:49:21 +00:00
Information for collecting logs is documented at the https://wayland.freedesktop.org/libinput/doc/latest/reporting-bugs.html[libinput website].
2018-06-19 19:49:52 +00:00
=== Sound issues ===
`alsa-info.sh` provides information about both kernel and userspace components.
If you have a working and non-working kernel, you should provide `alsa-info.sh`
for both cases.
2018-04-12 21:03:44 +00:00
== Bisecting the kernel
If the problem you've encountered isn't present in older versions of the
kernel, it is very helpful to use `git-bisect` to find the commit that
introduced the problem. For a general overview of `git-bisect`, see its
https://git-scm.com/docs/git-bisect[documentation]. An outline on how to bisect
the kernel is included in the
https://www.kernel.org/doc/html/latest/admin-guide/bug-bisect.html[kernel
documentation]. This guide contains Fedora-specific details.
[NOTE]
====
Bisecting is a time-consuming task, but it's very straightforward and is
often the best way to find the cause of a problem. If you're really interested
in getting the problem you're seeing fixed, bisecting will speed up the process
considerably in most cases.
====
. Find the newest version you can that works. This will be the initial "good"
2020-04-18 21:27:08 +00:00
version. The first version you find that doesn't work will be the initial "bad"
version.
2018-04-12 21:03:44 +00:00
2021-02-23 01:49:21 +00:00
. Install the xref:kernel/build-custom-kernel.adoc#_get_the_dependencies[dependencies]
2020-04-18 21:27:08 +00:00
required to build the kernel.
2018-04-12 21:03:44 +00:00
2021-02-23 01:49:21 +00:00
. Next, xref:kernel/build-custom-kernel.adoc#_getting_the_sources[get the source code].
2018-04-12 21:03:44 +00:00
. Prepare a `.config` file. Assuming you've got both the good and bad kernel
2020-04-18 21:27:08 +00:00
installed, the config for both will be in `/boot/`.footnote:[When bisecting
between major versions (e.g. `v4.16` and `v4.15`) new configuration options
will be added and removed as you bisect. It's _usually_ safe to select the
default.]
2018-04-12 21:03:44 +00:00
2018-06-18 18:18:57 +00:00
. Start a new `git-bisect` with `git bisect start`.
. Mark the newest version that works as "good" with `git bisect good <tag>`.
2020-04-18 21:27:08 +00:00
For example: `git bisect good v4.16.8`.
2018-06-18 18:18:57 +00:00
. Mark the first version that does not work as "bad" with `git bisect bad
2020-04-18 21:27:08 +00:00
<tag>`. For example: `git bisect bad v4.17`.
2018-04-12 21:03:44 +00:00
2021-02-23 01:49:21 +00:00
. xref:kernel/build-custom-kernel.adoc#_building_the_kernel[Build the kernel]. Sometimes
2020-04-18 21:27:08 +00:00
commits cannot be built. If this happens, skip the commit with `git bisect
skip`.
2018-04-12 21:03:44 +00:00
2021-02-23 01:49:21 +00:00
. xref:kernel/build-custom-kernel.adoc#_installing_the_kernel[Install the kernel].
2018-04-12 21:03:44 +00:00
2018-04-17 19:54:26 +00:00
. Reboot into the new kernel and test to see if it works.
2018-04-12 21:03:44 +00:00
. If the new kernel works, mark it as good with `git bisect good`. Otherwise,
2020-04-18 21:27:08 +00:00
mark it as bad with `git bisect bad`.
2018-04-12 21:03:44 +00:00
. Repeat the previous five steps until you've found the commit that introduced
2020-04-18 21:27:08 +00:00
the problem.